问题
According to this answer https://stackoverflow.com/a/41811770/2849613 I would like to get a little bit more information about best practices with microservices on Heroku.
The question is which approach is better?
- Install every services as independent app, and use one of them as REST "proxy" (for example Netflix Eureka)?
Or
- Create docker based approach with, for example Netflix Zuul as a load balancer?
On my own I see already some pros and cons of both approaches:
Pros: better scalability (easy to create new machines for bigger load). Cons: communication between services goes "outside of heroku" in other words: because heroku app have public address everyone can connect directly to service (without going threw Eureka), because of that every services need to provide some authentication method and share it between each other - I think that this is risk prone.
Pros: easy to reproduce production environment for tests and develop (docker image), communication between services is done "internally" (image to image instead app to app). Cons: hard to scale (I think that load balancing between Heroku apps and then docker images is a little bit overhead).
Which approach is better? Maybe I can mix them together? Or maybe there is some different, better solution?
Do be honest the only thing which I am sure, is that I want to use rabbitMQ as a message queue...
回答1:
I prefer approach #1 (especially since I know you're using Heroku already).
Docker is great, but the benefits are very limited if you're deploying on Heroku. The reason why is that Heroku already does everything docker does: manage dependencies, installation, and process management. Heroku does all this already for you without the extra work of Docker-izing your environment.
Regarding the load balancing: it doesn't actually matter. In both of your cases, if you want to run on Heroku, you WILL be using the Heroku load balancer. This is because there is no way to 'bypass' that layer of the Heroku stack.
If you want to use Docker / zuul, you'll need to do that OUTSIDE of Heroku for sure. This means you need to do all sorts of other stuff, find a docker host, manage your own infrastructure, etc.
So, in my mind, #1 is a better option (if you're using Heroku) because:
- Everything is already taken care of for you.
- You can focus on writing scalable code instead of managing all sorts of other things.
- All your services will be in the same AWS region, so even though they will talk to each other over HTTPs, it will be VERY FAST.
来源:https://stackoverflow.com/questions/41814001/heroku-load-balancer-vs-netflix-zuul