# Containers
Containers are the execution environment for microservices. Unlike virtual machines, it is recommended that containers run only one process at a time, launched from an image generated by a Dockerfile (opens new window) file.
Modyo Connect uses the serverless (opens new window) container service of AWS ECS Fargate (opens new window) to run containers in the cloud. With ECS Fargate, there is no need to configure platform servers, as they are managed by AWS.
# Programming Language and Framework
In Modyo Connect, microservices are developed using Spring Boot (opens new window) with Java, due to the simplicity of this framework for integration projects oriented to microservice deployments. Spring Boot does not require traditional application servers, as it defines its own execution runtime. In addition, applications developed with Spring Boot scale horizontally, allowing for a dynamic increase in the number of containers as required.
Within the container, the OpenJDK 11 (J9) (opens new window) runtime is used, which offers unique features of efficiency and compatibility.
# Container Image
Container images are generated in a continuous integration process, following user-provided definitions. Once generated, they are securely stored in the AWS Elastic Container Registry (ECR) (opens new window), which integrates directly with the AWS ECS service.
Below is an example of a container definition that allocates 75% of the available RAM to the Java JVM used by the microservice.
FROM adoptopenjdk/openjdk11-openj9:jdk-11.0.10_9_openj9-0.24.0
WORKDIR /usr/app
COPY build/libs/<microservice-name>.jar .
CMD java -XX:MaxRAMPercentage=75.0 -XX:MinRAMPercentage=75.0 -XX:InitialRAMPercentage=75.0 -jar -Dhttps.protocols=TLSv1.2 <microservice-name>.jar
# Instance Size
AWS ECS Fargate offers a wide variety of configurations (opens new window), from fractions of vCPUs up to 16 dedicated vCPUs per container. Depending on the number of vCPUs chosen, dedicated RAM ranges (1 GB to 32 GB) are activated. The consumption of MRUs varies depending on the node size.
CPU | Memory |
---|---|
1 vCPU | 2 GB ~ 8 GB (1 GB increments) |
2 vCPU | 4 GB ~ 16 GB (1 GB increments) |
4 vCPU | 8 GB ~ 30 GB (1 GB increments) |
8 vCPU | 16 GB ~ 60 GB (4 GB increments) |
16 vCPU | 32 GB ~ 120 GB (8 GB increments) |
It is important to consider that in production, the MRUs used by the component are multiplied by the redundancy factor required by the client (minimum 2 for multi-zone). Pre-production environments are configured without redundancy and may have fewer associated resources.
Fractions of vCPUs
AWS allows defining containers with fractions of vCPUs (e.g., 0.25 vCPU or 0.75 vCPU). However, applications running with a Java Virtual Machine (JVM), being a multi-threaded execution environment, do not benefit from deployments with vCPU fractions, as this generates I/O blockages that considerably affect their performance. Therefore, the minimum accepted for Modyo Connect is 1 vCPU and the maximum is 16 vCPU.
# Connection Pool
In many cases, a database connected to the microservices is required. It must be ensured that the database size is sufficient for the number of container instances considered (including the auto-scaling range). Concurrent connections to the database will be determined by the connection pool (opens new window) size defined in each microservice.
# Activation Steps
To request the creation of a container in AWS, a requirement ticket must be created in the Modyo Support Center (opens new window) stating:
- Name and location of the code repository.
- Branch from which the automatic deployment of each environment should be performed.
- Environment variables to be injected per environment.
Each container must be associated with a single code repository. The same branch cannot point to more than one environment (productive or pre-productive).
Learn more
For more information, please refer to the microservices development guide.