This topic uses the OnlineShop demo project as an example to describe how to build a local development environment for microservices applications.
Overview of OnlineShop
OnlineShop is a microservices demo project on GitHub. The project comprises Spring Cloud and Dubbo applications. It provides complete source code and well-built container images. Therefore, it can be used as a typical example in this topic.
OnlineShop provides three microservices: Frontend, Cart Service, and Product Service. Cart Service is a shopping cart microservice implemented by a Dubbo application. Product Service is a commodity microservice implemented by a Spring Cloud application. Frontend is a client microservice used to call the Dubbo and Spring Cloud applications. The following figure shows the architecture of OnlineShop.
As shown in the figure, the project provides only the service registration and discovery capabilities. It does not support production-facilitating microservices governance capabilities such as service queries, link monitoring, configuration management, and service authentication.
In this best practice, you can learn how to seamlessly migrate OnlineShop to Enterprise Distributed Application Service (EDAS) without service discontinuity and use the full-fledged microservices governance and application monitoring capabilities provided by EDAS.
Prerequisites
A Java environment is installed.
Build a local development environment for OnlineShop
Create cloud resources
- Create a virtual private cloud (VPC). For more information, see Create an IPv4 VPC.
- Purchase three Elastic Compute Service (ECS) instances that can be used in the created VPC. For more information, see Create and manage an ECS instance by using the ECS console (express version)Quick start.
- Install Java Development Kit (JDK) and configure a Java environment on the ECS instances.
- Download JDK 1.8 or later and Maven 3.5 or later.
- Log on to each of the ECS instances. Install JDK 1.8 or later and configure the JAVA_HOME environment variable.
- Log on to each of the ECS instances. Install Maven 3.5 or later and configure the MAVEN_HOME environment variable.
- Create a Microservices Engine (MSE) instance in the VPC and record the internal endpoint of the MSE instance. For more information, see Create a Nacos engine.
Configure the registry address in the configuration files of the microservices applications
In this example, the internal endpoint of the created MSE instance that serves as a registry is mse-****-nacos-ans.mse.aliyuncs.com:8848.
Deploy the microservices applications on ECS instances
Associate an Internet-facing SLB instance with the Frontend application
Send local access traffic to the Frontend application
Run the following command to keep sending local access traffic to the Frontend application:
while :
do
result=`curl $1 -s`
if [[ "$result" == *"500"* ]]; then
echo `date +%F-%T` $result
else
echo `date +%F-%T` "success"
fi
sleep 0.1
done