Online payment service PayPal says swapping Java for node.js on its servers is allowing it to serve web pages more rapidly and simplifying the creation of server-side software.
"Imagine an HTML developer who has to ask a Java developer to link together page A and B," he wrote in a blogpost.
"That's where we were. This model has fallen behind with the introduction of full-stack engineers, those capable of creating an awesome user interface and then building the application backing it. Call them unicorns, but that's what we want and the primary blocker at PayPal has always been the artificial boundary we established between the browser and server.
To enforce consistency in how servers are set up, important inside a large development organisation, PayPal created a convention layer on top of express called Kraken.js. Harrell said PayPal will open source Kraken.js soon.
PayPal's first use of node.js in production was to serve the 'Account Overview' section to its users. The company hedged its bets by building an equivalent Java application in parallel.
It took two node.js engineers a few months to build the necessary software, almost half the time it took the five-man Java team, with the node.js app written in 33 percent fewer lines of code and built using 40 percent fewer files. It also took a few months to complete the one-time step of building the infrastructure to allow node.js to work with PayPal — adding support sessions, centralised logging and keystores.
The node.js version of the app was built on kraken.js using express, the templating engine Dust and other open source code, while the Java software used an internal application framework based on Spring.
The applications contained three routes, with each route making between two and five API requests, orchestrating the data and rendering the page using Dust.
In performance tests on production hardware the node.js application responded to requests on average 35 percent faster than the Java alternative, resulting in the same page being served 200ms faster, "something users will definitely notice", Harrell said.
All of PayPal's consumer-facing web apps will be built on node.js in future.
"There are over a dozen apps already in some stage of this migration and we will continue to share data as more applications go live," Harrell said.