pnxtech / hydra-express

A module which wraps Hydra and ExpressJS into a library for building distributed applications - such as microservices
MIT License
184 stars 38 forks source link

Through Hydra Cli rest, we can see its load balancing and sending requests to running instances. But in typical web application to call hydra services, how can i configure to call with domain we specify without port? #124

Closed chandru-kumar closed 5 years ago

chandru-kumar commented 5 years ago

Through Hydra Cli rest, we can see its load balancing and sending requests to running instances. But in typical web application to call hydra services, how can i configure to call with domain we specify without port?

cjus commented 5 years ago

@ChandrewR Let us know whether the existing documentation is unclear. We'll be happy to improve it.

https://www.hydramicroservice.com/docs/hydra-core/messaging.html

chandru-kumar commented 5 years ago

Hi Carlos, Thanks for the reply..But what I am looking is how to call load balanced microservices in hydra. For example, i have a microservice runnning on two instances - http//ipaddress:7000/api and http//ipaddress:7001/api. I need to add domain and configure these two instances to 80 port to call as http//myservicename/api in Angular app without mentioning port - http//ipaddress:7000/api ..So it will get load balanced..Can you help me on this please? I dont see any docs for this..

cjus commented 5 years ago

I see. You could use something like NGinX. However, we use HydraRouter for this purpose. https://www.hydramicroservice.com/docs/tools/hydra-router/

chandru-kumar commented 5 years ago

Hydra-config

Hydra-service Hydra-routes

I have tried adding externalRoutes and didn't work..I made it as http as well and called the api as http://test-service.com/processfileapis/v1/getfilestatus and it didn't work. In doc, I'm seeing [get]/.... and is it mandatory to mention request type?

chandru-kumar commented 5 years ago

Not sure about this externalRoutes comes with Hydra-route(or i should implement NGinX and then use this approach) and how to use it to load balance? I couldn't see any sample project in Git Repo as well.. Can you please help sharing any examples, if you have?

cjus commented 5 years ago

@ChandrewR Hydra services can communicate with each other using internal load balancing which doesn't require a port. You can do that using hydra.sendMessage and hydra.makeAPIRequest. However, if you're sending a message from outside of hydra, as with an incoming web API request from a client on the Internet, then you'll need a tool which can route to one of several hydra enabled services.

NGinx and other load balancers have this support, as does Hydra-Router. This is more easily done when the hydra-services are running on different machines with their own IP addresses. That way the port address is the same for each service instance of the the same type.

Another popular way of handling all this is to use a Docker Swarm or Kubernetes cluster which has internal support for load balancing requests to containers.

All of this is more of a networking issue rather than a Hydra specific issue, as Hydra has support so that it works in all of the above situations.

I notice based on your posts times that we may be in compatible timezones. Let me know if you'd like me to setup a zoom conference call to we can speak about the above. I've love to see you up and running. If you'd like to do that send me an email to cjus34@gmail.com so we can setup a time. We'll then posts our findings here for future visitors.

chandru-kumar commented 5 years ago

Thank you Carlos. I will try setup with Nginx for load balancing and post the updates here..If I'm unable to make it, will send you an email to pitch in conference call. Tons of thanks for your time and answers so far.

chandru-kumar commented 5 years ago

Hi Carlos - I'm done. Its up and running with load balanced with NGINX setup..Thank you!!