Every young company faces the problem of scaling out infrastructure and increasing the throughput servers can sustain in order to provide a better customer experience and serve more customers without doubling resources.
Of course, caching static assets is a good way to alleviate the load in your web servers, but in our case the vast majority of traffic comes through our SDKs. As we scale, we are looking at different caching strategies to speed up our API servers in order to increase the throughput our infra can provide.
CDNs have come a long way since they were used to serve static assets like images (.png, .jpeg, etc.), Javascript files, and stylesheets (.css). After a bit of research, we found that CDNs like Fastly can be used to cache the results of API endpoints just as if you have a cache layer (Redis, Elasticache, Memcached) in front of your servers. Furthermore, CDNs have many POP (Points of Presence) all over the world, which means they are close enough to our customers to create only a small latency between the cached asset and our clients (the SDKs).
Caching alone is not enough when you look at speeding up your API services, however. The return values of your endpoints are very likely to change (sometimes very quickly), so the ability to immediately purge those cached values at the CDN edge play an important role in avoiding serving stale data for a long period of time. One of the features we like about Fastly is the instant purging time of the cached assets, which makes it one of the best CDNs out there when it comes to caching APIs. Solutions like CloudFront are less ideal in this case because their purging periods vary from 5 to 15 minutes. We also evaluated MaxCDN, which failed to match such a fast purging speed at the time, though they seem to be moving in that direction now.
In order to reduce the friction of interfacing with Fastly from Java, we contributed with a tiny Open Source wrapper for their API, which can be found in Github.
Take a look and let us know what you think—feedback and feature requests are always welcome.
And if this type of work interests you, we are always looking for great engineers to help us solve complex problems. Check out our job openings to learn more.
Get Split Certified
Split Arcade includes product explainer videos, clickable product tutorials, manipulatable code examples, and interactive challenges.
Switch It On With Split
The Split Feature Data Platform™ gives you the confidence to move fast without breaking things. Set up feature flags and safely deploy to production, controlling who sees which features and when. Connect every flag to contextual data, so you can know if your features are making things better or worse and act without hesitation. Effortlessly conduct feature experiments like A/B tests without slowing down. Whether you’re looking to increase your releases, to decrease your MTTR, or to ignite your dev team without burning them out–Split is both a feature management platform and partnership to revolutionize the way the work gets done. Switch on a free account today, schedule a demo, or contact us for further questions.