Coupa Software Scales on Ruby and Rails

 
 
By Darryl K. Taft  |  Posted 2013-10-16
 
 
 

Coupa Software Scales on Ruby and Rails


Coupa Software is big on the use of Ruby and Ruby on Rails for enterprise Web development, so much that it is pretty much all the company does.

San Mateo, Calif.-based Coupa is a spend management company, which means it helps companies control their indirect spending and generate savings by delivering such capabilities as e-procurement and expense management.

"We are a Ruby and Rails shop; we have been from the beginning," said David Williams, vice president of technology and founding engineer at Coupa, in a presentation at the company's headquarters. "That's pretty much all we do aside from the native code on our mobile applications and of course the JavaScript on the front end. But everything else is in Ruby. It's the core part of our business."

Coupa's Cloud Spend Optimization software-as-a-service (SaaS) product manages indirect purchases and expenses in real time. Built on Coupa's cloud architecture, it provides executive dashboards, alerts, expense management and real-time benchmarking in a single user interface. This spend optimization software suite focuses on three core spend areas, including procurement, accounts payable and expense management. Coupa is cloud-based and built on Amazon Web Services infrastructure.

Why did Coupa decide to focus on Ruby?

"When we started out we were quite small and all of us were coming from Oracle and we had a Java background," Williams explained. "We knew we wanted to build something modern, and Ruby was just so modern and it made us happy as developers. It meant that we could write much more concise code. It was a much better trade-off as to how much we could write how quickly. And especially in our business, where in enterprise software in general, you're not going to get a huge spike in users suddenly because you hit TechCrunch or something like that. You know how many users you're going to get. Your scaling problems are much more about the data and what you allow them to do.

"So for us it's a lot more valuable to be able to build out a lot more flexibility and configurability quickly than it is to be able to tune one thing to be very, very fast. But the way that Ruby makes us productive has been a wonderful boon for the company."

Ruby also helps Coupa solve one of the key problems of enterprise software in the cloud, which is how to support customization. Williams said in enterprise software, people have an expectation from big companies that they're able customize things to do exactly what they want. However, in the cloud it is difficult to support that gracefully.

"This means that we need to be as flexible as possible and support a lot of configuration and a lot of dynamic aspects to our product, but at the same time set some principles," Williams said. "And Ruby has been a really great way to make those compromises stick."

Coupa started out with Ruby 1.8.4 in 2006 and moved to the Enterprise Edition as it moved to Passenger as its application server. Beginning in mid-2011, Coupa started moving to version 1.9.3.

Now the company plans to move to Ruby 2.0 in 2014 and has a forward branch with some updates already in place.

Williams said Coupa is looking forward to a lot of the changes in 2.0, such as the updated garbage collector, as well as getting the "copy-on-write" semantics back that they had with Ruby Enterprise Edition, which reached end of life in 2012.

 

Coupa Software Scales on Ruby and Rails


"This is nice because it's all about throughput and scalability," Williams said. "In our system the fewer times you have to garbage collect, the less memory you take up per process, the more people you can put on the server, the better response time your users are going to get and the less hardware you're going to have to throw at it. So what's nice about the platform is it's quite horizontally scalable. We can throw more hardware at it if we need to, but it's nice not to have to. So that saves us money in the long term and saves our customers money as well."

Williams said the development team at Coupa is looking forward to lazy enumerators for the performance benefits there, as well as to named arguments.

In a post on DZone, Pat Shaughnessy, a Ruby developer working at a global management consulting firm, described lazy enumerators thusly:

"Ruby 2.0's new lazy enumerator feature seems like magic. In case you haven't tried it yet, it allows you to iterate over an infinite series of values and take just the values you want. It brings the functional programming concept of lazy evaluation to Ruby—at least for enumerations."

JP Krishnamoorthy, vice president of engineering at Coupa, said Coupa is "the most active spend optimization platform in the world." He added that as Coupa gives its customers and their users a consumer-like experience, "people are going to use the system more and more." Later, Krishnamoorthy asked Ruby creator Yukihiro "Matz" Matsumoto, who was on hand with a delegation of Ruby developers from Japan, what advice he had for enterprise software companies using Ruby.

Matsumoto replied, "The fundamental principle of Ruby goodness is focusing on the programmer, on people. As programmers we tend to focus on technology or the computer, as in how to make it fast and how to make it scalable. They are important, but if you are building software applications that target humans, don't forget to focus on humans."

Coupa's platform handles 500,000 transactions daily and supports $43 billion in spend through. "As a Rails app we have 241 controllers, almost 500 models and 130,000 lines of code," Williams said. "For a Ruby project this is fairly large; for a Java project not so much."

Since its launch in 2006, the company has continued to grow quickly. In fact, recently Coupa moved its development team to a nearby location because it had filled the existing facility to capacity.

Coupa's longer-term challenges include scaling more and more as the company grows.

"We already scaled past this office, we're scaling in employees, in customers, in users per customer, in data volume, in size of customers," Williams said. "So everything we can do in the language, in the platform, in our code to make scalability easier is a good investment from our perspective. So some of that will be getting into more thread safety. This is something that is mostly a librarian testing issue. We're also looking at multi-core support. We may end up exploring JRuby or Rubinius, but that's longer term."

Another thing Coupa is looking at is sandboxing untrusted code, Williams said.

"One of the lovely things about Ruby is how flexible and powerful it is wherever you happen to be, but it can also be really dangerous if you have code in there you don't trust," he said. "It can be hard to make sure you're masking everything that you need to mask in order to not let something play havoc in your system. We've played with a few different options there. One is to use service-oriented architecture for some things, but that limits your flexibility. There's the potential of embedding a different language altogether, like Lua or JavaScript, which makes drawing the lines easier. But that also means you have these interfaces to figure out, and that's not as elegant as it could be."

 

Rocket Fuel