- Cloud-Native Applications in Java
- Ajay Mahajan Munish Kumar Gupta Shyam Sundar
- 283字
- 2021-06-24 19:07:17
Service registration and discovery
Why is service registration and discovery important? So far, we have been calling the service through its URL, which includes the IP address—for example, http://localhost:8080/prod—thus we expect the service to run at that address. Even though we might substitute the test and the production URLs, the step of calling the service at a particular IP address and port is still static.
However, in a cloud environment, things are quite dynamic. If the service goes down at a given IP, it can come up in a different IP address as it comes up on some container. Although we can mitigate that with virtual IPs and reverse proxies, it would be better to look up a service dynamically at the time of the service call and then call the service at the IP address. The lookup addresses can be cached in the client, so that the dynamic lookup need not be performed for each service call.
A registry (referred to as a service registry) helps in this case. When the service boots up, it registers itself in a registry. There is also a heartbeat between registry and service to ensure that the registry keeps only live services in its registry. If the heartbeat stops, the registry deregisters that instance of the service.
For this quick starter, we are going to use Spring Cloud Netflix, which nicely integrates with Spring Boot. We need three components now:
- Product service: We have already written this
- Service registry: We are going to use Eureka, which is part of Spring Cloud
- Service client: Instead of calling our service directly through a browser, we will write a simple client to our service
- 常用元器件的識(shí)別與檢測(cè)
- 現(xiàn)代數(shù)據(jù)通信技術(shù)與應(yīng)用
- 高效變換器設(shè)計(jì)與應(yīng)用電路
- LED照明技術(shù)與應(yīng)用電路
- 5G無(wú)線網(wǎng)絡(luò)優(yōu)化技術(shù)原理與工程實(shí)踐
- 6G時(shí)代的按需服務(wù)衛(wèi)星通信網(wǎng)絡(luò)
- LTE無(wú)線網(wǎng)絡(luò)優(yōu)化
- 視頻精講:PADS 2007原理圖與布板設(shè)計(jì)典型實(shí)例
- 基站主設(shè)備及配套設(shè)備維護(hù)
- 4G無(wú)線網(wǎng)規(guī)劃建設(shè)與優(yōu)化
- 通信對(duì)抗偵察信息處理技術(shù)
- 通用數(shù)字集成電路簡(jiǎn)明速查手冊(cè)
- 光通信技術(shù)與應(yīng)用
- Photoshop手機(jī)App界面設(shè)計(jì)實(shí)戰(zhàn)入門(mén)
- NFC技術(shù)原理與應(yīng)用