When a microservice starts up, it goes through several steps in its lifecycles, i.e. Assembly, BootStrapping, Discovery, and Monitoring.
Service assembly:
packing all the source code and all its dependencies, together with its runtime engine in a single installable artefact.
It can eliminate the traditional Configuration drift problem, which is due to server configuration and source are managed by different admin team and development team respectively.
It can quickly deploy the micro-service in response to a sudden influx of requests.
Service bootstrapping:
The key point for service bootstrapping is how to manage its configuration file.
Distributed microservice instances often run into the same type of configuration requirements. With a high number, and geographically dispersed services, becomes unfeasible to redeploy services to pick up new configuration data. Storing configuration externally solves this problem.
The configuration store should close to the service, and with minimal latency. The most important configuration store should always up running, otherwise, it would become a single point of failure.
When a microservice instance comes up, it calls an ending point to read its configuration, which resides in a repository that may be a relation database, files under source control, or a key-value data store.
Changes to configuration management are typically handled through the build and deployment pipeline where changes of the configuration can be tagged with version information and deployed through the different environments.
When making a configuration change, services consuming it must be notified and refresh their copies.
Service discovery
From a client perspective, microservices should be IP transparent; all service instances behind one microservice are considered as the same physical resource. Microservice normally maintain a short life cycle, and it has a unique but non-permanent IP address assigned to it. In this way, it achieves a high degree of scalability and availability. a microservice needs to register itself with the third-party agent, thus exposing itself by a logical name, rather than a permanent IP.
Service monitor
Most service instances will expose a health check URL that will be called by the service discovery agent. If the call returns an HTTP error or doesn't respond in a timely manner, the service discovery agent can shut down the instance or just not route traffic to it.
Service discovery agent monitors the health of a service instance. If the instance fails, the agent will remove it from a pool of available instances.