RESTful APIs have become increasingly popular both among web services and developers and are easy to serve up with the same software used for regular web pages. In May of 2010, 74% of web APIs used REST as their protocol.
When setting up servers for a REST API it can make sense to use a web server software that is a bit more lightweight than what you’d use for a full-blown website. The gains are, at least in theory, that each API server that way could handle more requests since it would be less taxing on system resources.
But is that what actually happens, or do most web services just put up an Apache server, same as they would do for a regular website?
Since we’re working on a new REST API ourselves here at Pingdom, we were curious about this and decided to find out.
Web server software used by websites
Before we show you which web servers are most common for serving REST APIs, let’s first recap which web servers are the most common for serving regular web pages.
On the traditional Web, Apache is king of the hill and has been so since before the dinosaurs roamed the Earth. This is shown month after month by Netcraft’s web server survey. For example, for the month of November, the top three web servers were:
- Apache: 59.4%
- Microsoft IIS: 22.7%
- nginx: 6.0%
Apache and IIS need no introduction, and in case you haven’t heard of nginx, it’s a lightweight, high-performance web server that has been gaining in popularity the last couple of years. We wrote about its rise to fame earlier this year.
Now let’s examine which web servers are most common for serving REST APIs.
Web server software used by REST APIs
A good resource for finding web API listings is Programmable Web, which is what we used in this article. We filtered out the REST APIs that had been updated during the past 60 days, removed duplicates for APIs from the same provider, and ended up with a list of 127 APIs. It included a mixed bag of APIs both from big players like Google and Paypal, as well as plenty of smaller services.
The relatively modest sample base we used means that these numbers won’t be super exact, but they are good enough for our purpose, which is to estimate which web servers are currently the most common for REST APIs.
We accessed all those APIs to see what kind of server would respond (by reading the HTTP response header) and got the following results:
A few observations:
- Apache is almost as common for serving REST APIs as regular web pages. This was perhaps not too surprising considering that it is highly mature software and above all is a well-known entity among webmasters. It might actually be more common than what is shown here, as we’ll explain here below in the bullet point about nginx.
- Nginx is significantly more common here than it is for serving regular web pages, although it’s still far behind Apache. It’s a huge jump for the little web server. However, since nginx is sometimes used as a load balancer (in front of example Apache servers) it’s difficult to tell how many of these APIs use it as an actual replacement for Apache. That said, nginx does have several properties that should make it suitable for serving up a web API, such as a very light system load and the ability to handle a huge amount of simultaneous connections.
- Microsoft IIS is in a relatively distant third place when it comes to serving REST APIs.
- These three web servers together make up more than three quarters of the web server software used.
Since images tend to illustrate these kinds of differences better than words, here’s a visual breakdown of how web server usage differs between websites and REST APIs:
And a small side note regarding the “Others” category in the first chart. We lumped together all of those we only found one of: GSE, Cherokee, Jetty, Lighttpd, Node, Virtuoso, YAZ, Mongrel, Resin, PasteWSGIServer and mafe (this last one from Google Maps…).
Final words, and a question
To be honest, we had expected Apache to be slightly less dominant in the world of web APIs than it turned out to be. However, people like to work with what they’re used to, which we suspect is a factor here. (We’re not implying that Apache is a bad web server.)
We haven’t decided yet what we’ll end up using for our new API. If you have built, or are building, a REST API, we’d love to hear your opinion. What web server are you using, or plan on using? What do you think is the best tool for the job?