How (and Why) Netlify Uses NATS
Web developer Netlify had a choice to make for its messaging: RabbitMQ or NATS. Here's why they went with latter and what it offers.
Join the DZone community and get the full member experience.Join For Free
the traditional way of making websites is being disrupted by technologies like static site generators, build automation, and cdn hosting. netlify is building the modern day platform that developers and companies use to manage and publish their content online. launched in march 2015, netlify already serves close to a billion page views per month for thousands of developers and clients such as wework, wikia, sequoia capital, uber, and vice media.
at netlify, i am the head of infrastructure. that sounds like a devops job (and some days it is), but it means that i build out the backend platform that powers our 70,000+ sites. our platform spans most of the cloud providers — rackspace, aws, google cloud platform, digital ocean, and our own anycast network. we do this to leverage each provider's strength and nimbly move between them when we face problems, such as provider outages or ddos. we use go, ruby, c/c++, rabbitmq, ats, ansible ( playbook here ), mongodb, and, the subject of our discussion today, nats .
our data plane is designed to be where our services dump data like metrics and log messages. other interested parties can hook up and consume the data stream. we have been debating between using rabbitmq and nats for the message bus. we already use rabbitmq for our command and control plane, but we've experienced some administration headaches and cumbersome client code. in addition, we were concerned about the throughput, and we didn't need the enterprise messaging features (e.g. topic durability, guaranteed delivery) that rabbitmq provided. the decision to use nats was based on the performance, easy setup, and clean client code.
for a concrete example, let's look at how we built our logging framework. we have two types of services, ones that we wrote and ones we use (e.g. ats). for the ones we wrote, we have standardized to log with logrus with a nats hook . for services where we can't edit the code, we use a log tailer to dump those logs to nats. now that the data is flowing through nats we have a handful of services that act on that data. one such service is elastinats ; it listens to different channels and then pushes them to elasticsearch. now we have a searchable, unified view of our platform. this has been immensely helpful in detecting and diagnosing problems that come up when running a large distributed system.
when building out this system i uncovered a little bug . after confirming that it was indeed not my code — which had a non-zero chance of being the culprit — i reached out to the community over the mailing list, was quickly added to slack (you can request an invite here ), and now i am part of the community. community engineers and the nats team jumped on the issue and hammered out a solution in a few days. this quick turnaround between bug discovery to fix confirmed that i had chosen the right messaging system for our next iteration of our architecture.
getting access to our own data via nats was the first step, and now it is a question of what we can dream up. at netlify we are very excited about all the ideas we've had and new features this is going to enable. we are also very passionate about open-source , we look forward to giving back to the nats community.
if you have any questions or would like to know more, feel free to find me in nats slack, or on twitter !
Published at DZone with permission of Ryan Neal. See the original article here.
Opinions expressed by DZone contributors are their own.