Scaling NATS For Education
NATS is an open source messaging system known for its simplicity and performance. NATS is becoming popular as a result for IoT messaging, Microservices Messaging, and Cloud Native Messaging.
Join the DZone community and get the full member experience.Join For Free
this is a repost of a blog post contributed by matt farmer to the nats blog . nats is an open source messaging system known for its simplicity and performance. nats is becoming popular as a result for iot messaging, microservices messaging, and cloud native messaging.
in this article, matt shows how the australian government use nats as a part of their national schools interoperability program - nats provides a simple and fast backbone that doesn't require them to rethink their architecture each time, since nats makes no underlying assumptions about the audience/infrastructure it is integrating with.
our nats-powered validation services in action
i’d like to focus for this blog on what nats has helped us to achieve. there are a whole set of other great entries on this site looking at various aspects of technical implementations, and the nats community as a whole is incredibly responsive and helpful; so if you have questions about how to do something just have a read around here, and you can always ask a question in the nats slack channel for pretty much immediate gratification.
for this post, though, i want to look at what using nats has enabled us to do, which wasn’t really possible before - i’m hoping our example might make it clearer quite why you would choose to use nats in the heart of your product if you face business needs in any way like ours.
first a bit of background on who we are. i work for a small government unit here in australia called nsip ; the national schools interoperability program, you can tell we’re a government unit from the catchy name. we’re funded by both the federal government and the states and territories to try and ensure that technology in education can achieve the best outcomes for students by allowing data from the multitude of possible sources - web applications, assessment programs, classroom apps, student administration systems - to work together to give a coherent view of the learner.
a lot of our work is in the policy and architecture space learning services architecture , and a key part of our success is that we work hard with the ed-tech community of solution vendors here in australia to get agreement on how to make this happen - we don’t just invent ideas in a vacuum, and every initiative is road-tested with the people who have to actually do the real work to ensure that we all move forwards in a collaborative and effective way.
so where does the technology come in? well, first of all we’re not a product house. we don’t create things that you can buy, or provide services that you can run.
where we intersect in the technology space is to identify those structural gaps that need tools to fill them, to create those tools as open source components, and then make them available to all our stakeholders to use in solving problems; especially problems in the integration space. integration problems are some of the hardest to address structurally since it can often be the case that it’s not clear in a classic market relationship quite who has responsibility for solving them - vendors rightly will concentrate on putting new features into their product sets, but who creates the links to other packages or data sources, and what’s the incentive to do so.
we can’t provide any direct incentives, but what we can do is create open source tools to solve those problems and then make them available to everyone to embed or use as easily as possible.
our latest toolset is a suite of services that provide a whole bunch of useful integration tools. in the popular language of today you could call it a micro-services architecture. my only hesitation in actually calling it that is that i feel increasingly like the will munny character in ‘unforgiven’ - “i’ve sent messages across every protocol that walks or crawled at one time or another” - i fell in love with message-based architectures a long time ago, have always felt them to be inherently helpful in dealing with complex problems, and here we all are in the wonderful world of reactive systems.
i’m truly glad that the rest of the world has caught up with us queue-junkies, but sometimes with a little bit of that feeling when the obscure band you loved suddenly gets famous and everybody else loves them too. okay, enough with grizzled neck-beard nostalgia - if everyone loves messaging that’s all to the good with me.
our toolset is known as nias (nsip integration as a service), and i want to talk about one particular subset of those services and how nats has helped us.
each component of nias is a standalone utility that does something useful, and all of the services communicate over a messaging backbone; nats and soon stan as well.
there’s a whole bunch of these services; privacy filtering, a small ‘graph’ datastore that links entities from different inbound data models, lightweight analytics, and the set i want to focus on here that specialize in data validation.
so here’s our validation scenario. schools and school authorities need to register students for online national assessment. for that to work well, there’s a whole set of business conditions that need to be tested. are students in the right year groups for the tests based on their birthdates, are there duplicate records for students, are they enrolled in more than one school, does the supplied data match the required schema for structure and content etc. etc.
modeling and implementing each of these as a discrete validation service makes them nice and easy to reason about. by running them all against a messaging backbone and using queue groups in nats it becomes easy to run all of the validations in parallel, and on top of the raw nats performance the end result for the user is a very quick validation cycle.
so far, so good, we’ve covered two of the great features of nats; it makes micro-services easy to construct, and its performance means that most people don’t even know they are using a message-driven stack.
but here’s the aspect i really wanted to highlight from our experience, the ability to deploy at all scales without changing anything in our architecture.
as we don’t run services, our tools need to be able to run in every possible user configuration.
this means that the package of services and gnatsd are just a single set of binaries. for many of our users they take that group of binaries and with the magic of a batch/shell script, they simply run it as a standalone desktop application.
an operation such as schema validation can be resource intensive. want to give it some more processor power; just start more instances of the schema validator service. queue groups mean instant parallel processing.
want to really spread the load, just start each of the services on different machines.
want to run enough services for a full state-level implementation, just put groups of services on the hardware that you want, literally just start them up where you want them to be.
want to have dedicated process clusters on behalf of states or jurisdictions, such as specialized handling for all schools in the catholic sector, just start a bunch of the services and give them appropriate names.
the beauty of nats is: no-one has to know anything about the system configuration in order to do this.
for us, one of the greatest strengths of nats is not just the performance and the stability, it’s the overarching philosophy of providing really helpful, pragmatic real world behavior out of the box.
i love messaging patterns, they really help especially in the integration space. the thought that in order to get that benefit for a standalone user would mean providing install instructions for a typical enterprise messaging backbone would make such an approach just untenable in terms of support for a small team like ours.
yet here we are, one simple codebase (yay golang), that is ready to deploy on any target system; windows, mac, linux, and yet can be configured for every possible topology required from single user desktop application, all the way through to massively distributed and horizontally scaled. and thanks to nats no-one has to know how to do anything other than start up the services they want.
you could rightly point out that some of the benefit comes from choosing the right architectural model, micro-services, reactive patterns etc., and that would be true. the great thing about nats is that it makes those choices something that can be operationalized and repeated at all scales with the very minimum of effort.
that makes a huge difference when you are a small team trying to solve difficult problems so that others can benefit. the raw engineering of nats is truly impressive and we love the performance, but it's the fact that we can scale our tools to meet any possible usage scenario from single-user to cloud-scale without having to rethink our architecture or deployment that makes nats a crucial differentiator for us.
you can find all of our stuff (rough and ready though it may be) on our github account nsip github , and we are always keen to share and help especially those of you out there also in the ed-tech domain.
Published at DZone with permission of Brian Flannery. See the original article here.
Opinions expressed by DZone contributors are their own.