Reputation: 577
I am using Node.js and a REST based light weight web service to communicate between servers. i want to know if there is another more efficient way to communicate between servers? I am using ec2 instances in a vpn.
Upvotes: 3
Views: 1882
Reputation: 8331
There are few options:
if you have not too many microservices, they are beefy, with a lot of ACL/scoping logic in inter-service communication, nothing is better than good old REST via HTTP/1.1. It is default most basic language of the web, and any language have loads of good REST-connectors, which makes development of the communication breeze.
if there are many services, message persistence required, and distributed transactions of any sort are unavoidable then the choice is powerful u-boat message-bus like RabbitMQ (AMQP). Any other messaging protocols/queues could be used (ZeroMQ/via Redis) - and the choice depends what traits are mandatory for your system ISC.
IPC (via TCP or UDP), as mentioned above - the preference over this option depends on the language in which your services written, as doing this in some languages is easier than in others, and this requires most of the code written (and if there few languages in your system - this will need to be written in each of them)
Sockets, as mentioned above.
My personal favorites are top 2 - one offers simplicity and familiarity, other speed and robustness and control.
Upvotes: 1
Reputation: 671
The above 2 answers are perfectly fine. I would want to know if you're looking forward to using Docker so as to support your microservices efficiently and have more visibility and security. So, far it is being used as the most popular microservices architecture component.
This is a good read: https://medium.com/aws-activate-startup-blog/using-containers-to-build-a-microservices-architecture-6e1b8bacb7d1#.qztlom227
Upvotes: 0
Reputation: 111316
More efficient than REST over HTTP will be, from least efficient to most efficient:
But this difference may be completely irrelevant if your miscroservices are actually doing anything useful and don't spend most of their time handling the HTTP headers.
For example, when you spend half a second waiting for the database and then return a megabyte of JSON then adding few additional lines of HTTP headers can be even not measurable.
You need to profile your code and test it before doing premature optimization and keep in mind that some of those ways to communicate more efficiently in terms of sending less bytes, can be much less efficient in terms of development time, maintenance and debugging. Keep in mind that nothing is easier to inspect and debug than text based protocols like good old HTTP/1.1 that you can talk to using netcat or anything else that handles plain text.
Upvotes: 7