BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Scaling the ipify Service on Heroku

Scaling the ipify Service on Heroku

This item in japanese

The developer behind the ipify service shared his experiences in scaling the service to 30+ billion requests on Heroku. ipify is an online service which exposes an API that applications can invoke to fetch their external IP address. The service, initially written in node.js, was rewritten in Go to obtain better scalability.

ipify was started by Randall Degges to solve a need in one of his projects. The first version was written in node.js and deployed on Heroku. The service was accessible via tools like curl so that it could be used programmatically. The website was a simple front end deployed on CloudFront backed by an S3 bucket. Heroku has server units called dynos, the smallest of which offers 512 MB RAM and 1x the underlying CPU share. Heroku was the service of choice here as it was low-maintenance - it could auto restart on failure of the process and had a load balancer in front. This initial setup cost around $7/month. Heroku being hosted on AWS, could also leverage AWS's underlying reliability.

The service’s popularity revealed some scaling issues, which could not be solved by adding more hardware. Some investigation revealed that the throughput was just around 10 requests/second. Some improvement was achieved by using the node cluster module, which launches multiple processes to take advantage of multi-core systems. When this was found insufficient to handle the increasing traffic, the service was rewritten in Go.

Go's httprouter package was chosen for its performance over other options. The rewritten service performed significantly better, taking lesser memory (around 5 MB) and handling 2000+ requests/second from a single dyno deployment. Some further improvements in string handling led to a performance gain of an additional 1000 requests/second. This brought down the cost as well, running on the single dyno. Similar services like ipinfo.io hosted on AWS also faced scaling issues which translated into higher costs, with monetization of the service being one solution.

ipify was being used not just by regular developers but also by malware writers, which led to a large amount of spiky traffic. This led to it being blocked by antivirus vendors based on public blocklists. The current usage of the service peaks at around 30 billion requests per month, with an average response time of between 1 to 20 milliseconds. Other services -- some of which provide geolocation also -- have rate limits unlike ipify.

ipify's client libraries are available in several languages.

Rate this Article

Adoption
Style

BT