Come eseguire la scoperta del servizio per gli endpoint di riposa di avvio a molla

StackOverflow https://stackoverflow.com//questions/23044094

  •  21-12-2019
  •  | 
  •  

Domanda

Se ho più contenitori di Tomcat incorporati a molla e ciascuno può avere endpoint del servizio come

http://localhost:8080/employeeSelfService/getDetails
http://localhost:8081/employeeSelfService/getDetails
.

Come può fare il bilanciamento del carico utilizzando 2 micro servizi in modo tale che i client possano colpire uno qualsiasi degli URL citati in base a una catena di bilanciamento del carico

un'opzione che viene in mente è quella di utilizzare Netflix Curator (o) avere un server web Apache che agisce come proxy inverso ma con Apache, quando crei nuove istanze dei servizi, avrai una voce di quel servizio come aMembro in httpd.conf

Stivaletto a molla fornisce qualsiasi rilevamento del servizio e meccanismo di bilanciamento del carico?

È stato utile?

Soluzione

Boot a molla non fornisce questa funzione, poiché è già stato fornito da un proxy inverso come Apache / NginX in esecuzione davanti al server di avvio a molla.

Vedi qui per un esempio Come la versione commerciale di Nginx fornisce la funzionalità di dinamicamenteScalare e riduzione dei nodi a monte .

Quindi in questo caso è per l'istanza dinamica, in questo caso il processo di avvio della molla per segnalare la sua presenza / annullamento stesso al server upstream a inizializzazione / spegnimento.

Vedi qui Come farlo nel caso di nginx, questa procedurasarà diverso dal server al server.

Altri suggerimenti

Arguably it's not really an application's role to manage its own load-balancing, and Spring Boot focuses on the implementation of an application (or service, equivalently). We have been thinking about whether we could provide features in Spring (Boot or otherwise) to make it easy to write your own load-balancer, or service registry app, but even then I don't think that was what the question was really about (or was it?).

If I interpret the question, and the example use case, literally, I would say that the most natural answer is an out-of-the-box reverse proxy solution (as the other answers pointed out). I also note that such a reverse proxy is an essential and natural part of a PaaS solution, so if you need it to "just work" and don't want to know about the details, PaaS would be a natural path (e.g. see cloudfoundry as an example of such a solution that I happen to have worked on).

Indeed Spring Boot has not inherit support for load-balancing. Just to add to the list of available solutions for load-balancing, here are the instructions to configure an Apache for load-balancing.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top