Redis powered Microservices using Hydra
Hydra is a NodeJS npm package for building distributed computing applications such as Microservices. The Hydra open source project consists of a growing ecosystem of tools that are enabling developers to embrace microservices on their projects and within their organizations.
A key goal of the Hydra project is to lower the barrier for building and deploying scalable Node microservices without sacrificing robustness and scalability. As a light-weight library, hydra-core has been used in a wide range of situations from small IoT devices to Dockerized cloud infrastructure.
Hydra leverages the awesome power of Redis to address the following microservice concerns:
- presence and health monitoring
- service discovery
- route discovery
- inter-service messaging
Let’s examine each of those.
Presence and health monitoring
Microservices need to communicate their presence status so that they can be monitored and reliably communicated with across a network. Sending messages to an unhealthy service can have cascading consequences depending on the robustness of your application architecture.
Applications need to know the status of peer microservice in advance of calling them. So that routing software can avoid unhealthy services and report problems before they become fatal.
A microservice using Hydra stores its presence and health status in Redis where that information is available to peer services and monitoring agents.
Service Discovery
Distributed applications work together by sending messages to one another. Most often those messages are in the form of HTTP Restful APIs. Another common approach is socket-based messaging.
To work with one another, applications need to know the location of peer services. That is, they need to know the target IP and Port addresses. The use of DNS entries or a reverse proxy server such as Nginx can partially address this concern. However, the downside of this approach is that those solutions require management. Meaning, there is no automatic or dynamic discovery occurring.
Hydra-powered services can register their service name, IP address and Port with Redis. Combining registration and service presence information allows peer services to discover one another.
Route Discovery
Applications using Hydra can register their Restful API routes so that peer applications can discover them. The Hydra-Router, a dynamic and service aware router, uses the stored route information to direct external requests to services within a cloud or cluster environment.
Inter-service Messaging
Redis offers a messaging service to allow applications to publish and subscribe to messages. This communication is socket-based and highly performant. Hydra adds a layer above Redis messaging to enable applications to communicate with each one another by sending JSON messages containing routing information such as named services. There’s no need to think about IP addresses or Port — or even which service instance will receive a message.
The flexibility of Redis
Redis is ideal for many reasons, and its popularity among developers continues to soar. It also ranks favorably in online polls.
Redis is also likely to already be in your environment as it’s often a go-to solution for intelligent caching. However, Redis is so much more!
A key reason for building Hydra on top of Redis is because Redis is available on IoT devices, laptops, cloud infrastructure and well supported by hosting environments such as RedisLabs. This truly empowers developers to build and deploy Node microservices to any of those environments.
Learn more at https://www.hydramicroservice.com