How replacing Java with JavaScript is paying off for PayPal

How replacing Java with JavaScript is paying off for PayPal

Summary: PayPal reveals that writing server-side software in node.js rather than Java is allowing it to serve web pages more rapidly and simplifying web development.

TOPICS: Web development

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.

PayPal has moved from building web applications using Java to using JavaScript in the browser and node.js on servers.

Node.js is a platform built on Chrome's JavaScript runtime that allows engineers to build fast and scalable network applications using JavaScript. Node.js is suited to creating data-intensive, real-time applications that run across distributed devices using its event driven, non-blocking I/O model.

Jeff Harrell, director of engineering at PayPal, described the architectural advantages of shifting from Java to JavaScript.

"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.

"Node.js helps us solve this by enabling both the browser and server applications to be written in JavaScript. It unifies our engineering specialties into one team which allows us to understand and react to our users' needs at any level in the technology stack."

PayPal started using node.js as a prototyping platform but this year moved to using it in production. The team at PayPal started on node.js using the web application framework express, the JavaScript task runner Grunt and nconf for configuration.

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.

Simpler, faster

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.

The results of PayPal testing the two apps. Image: PayPal

 Further reading

Topic: Web development


Nick Heath is chief reporter for TechRepublic UK. He writes about the technology that IT-decision makers need to know about, and the latest happenings in the European tech scene.

Kick off your day with ZDNet's daily email newsletter. It's the freshest tech news and opinion, served hot. Get it.


Log in or register to join the discussion
  • should have used Vaadin

    Would not have to replaced Java.
    Java script is a nightmare to maintain those people say otherwise has not had to maintain a large code base.

    You can always improve the performance of new code. So not impressed with improved performance figures.
    • The problem with Javascript is not the Javascript

      It is that JS developers are invariably tempted to add jQuery - which adds a whole rat nest of code that is close to impossible to debug.

      Javascript can be written clean with classlike functions in a pseudo object oriented fashion. As long as you can avoid the temptation to pollute your app with tons of downloaded libraries (judicious thought out use of these is OK).... then you should be good.
    • Douglas Crockford discusses the issue of handling a large JS code base

      In this recent Hanselminutes podcast:
      Nick Heath
  • "PreyPal" ...

    Regardless, eBay Inc. is demonstrably the greatest calculated facilitator of auction fraud on consumers that the world is ever likely to know ...
    The ugly reality of eBay Inc.:
    eBay's crooked auctions marketplace ... bit(DOT)ly/11F2eas
    eBay Motors: Auction Fraud Galore … bit(DOT)ly/I2gTEU
    eBay's clunky, unscrupulous "PreyPal" ... bit(DOT)ly/UVXx53
    The ongoing joke of it all ... bit(DOT)ly/YvxFEg
    Fun quotes from the eBay executive suite ... bit(DOT)ly/12xvzyA
    Philip Cohen
  • May be Misleading articale

    The benefits quoted must be meant to mislead and cover their bad investment. If engineers does not know how to write and tune Java Code, they can never be good JS coders for sure. I am aware of Technical Debt in ebay companies and know, how they are loosing to competition as they are not as fast as their competition to demanding business needs.

    See this

    TejaSoft research show that, JavaScript would be the client side monster which will not die until browsers start supporting other modern languages (scala or groovy), however the winners are not who write JavaScript products and frameworks manually, but who can generate JavaScript Products and frameworks. This is the way to be in JS products and frameworks business for longer term without suffering/lagging on development, testing and maintenance due to cross browser issues, high skill needs and be faster and cheaper than competition any time.

    May be paypal should allow public review of their work quoted, then things would be more believable.

    It is close to a year since this article came in, may be they should re-tell the current status of this change specially on how slow they are on maintenance and people productivity.