Microservices and Serverless: The “Babies” in the Software World
1. Introduction: The “Divide and Conquer” Era of Technology 4.0
If the traditional Monolithic application is like a massive elephant difficult to move, Microservices are like an army of ants – small but incredibly efficient. And Serverless? Imagine having a team of “Ninjas” ready to appear when needed and… vanish once the job is done! 🥷
Why are they so popular?
- Because everyone loves “small but powerful”.
- Cost-saving (Everyone loves that!).
- Easy to “upgrade” like replacing old clothes with new ones in your wardrobe.
2. Microservices: When Software Knows How to “Split”
Definition:
Microservices is a software architecture style where the application is divided into independent, compact services (Microservices), each service:
- Performs a specific function.
- Has a clearly defined interface and operation.
- Is deployed on a separate server, making it easier to upgrade and scale.
Example: Microservices are like a buffet restaurant – each dish is prepared at its own station, by its own chef, but all contribute to one delicious meal!
Comparison with Monolithic:
Monolithic = A basket of eggs (drop one, and they all break).
Microservices = A fridge, egg trays, a basket of eggs (drop one, and there are still more eggs in the fridge).
Advantages:
- High independence: Services operate independently, easy to deploy and update without affecting the entire system.
- Scalability: You only need to scale the services that require more resources, saving more costs compared to Monolithic.
- Reliability: A failure in one service does not disrupt the entire system, improving stability.
- Independent teams: Multiple teams can develop different services concurrently, speeding up development.
Disadvantages:
- Complex management: Requires managing multiple services, including deployment, monitoring, and error handling.
- Communication challenges: Services communicate via API or messaging, which can lead to errors if not synchronized properly.
- High cost: Requires more resources, both in terms of infrastructure (tools, platforms) and personnel (skills in development and operation).
- Debugging challenges: Identifying errors in a distributed system requires more tools and expertise.
Image illustrating the Microservices roadmap for developers.
3. Serverless: The “No Home, No Roof” Story But Still Thriving!
Definition:
Serverless is an execution environment and platform for applications and services that doesn’t require worrying about servers. Serverless applications don’t need to handle resource allocation, operating system management, upgrades, or security. Focus solely on product development, while the platform takes care of the operations.
Serverless is like living in a luxury rental home – you just live and pay, everything else is handled for you!
Popular Services:
- AWS Lambda.
- Google Cloud Functions.
- Azure Functions.
4. Combining Microservices and Serverless: The Perfect Couple!
Just like coffee and condensed milk, Microservices and Serverless are a match made in heaven. When combined, they bring three amazing benefits:
- Optimized operational costs: You only pay for what you actually use, no more wasting resources. This makes executives smile with satisfaction.
- Flexible scalability: The system easily meets the growing needs of businesses. Customers are satisfied because the service is always smooth and stable.
- Simplified operations: No more sleepless nights worrying about servers. The development team can focus on creating valuable features instead of worrying about infrastructure.
5. Microservices in E-commerce Applications
To understand and build a simple E-commerce system, each service is an independent project, with its own database and can be deployed separately.
Image of an E-commerce system applying Microservices.
Our E-commerce system is built with five key services:
- “Product Management” Service: Handles storing product information and images in the database. This service processes all user requests for viewing and browsing products.
- “Cart” Service: Allows customers to add or remove products from the cart. When changes are made, the information is updated in the database and notified to other services through a Message Broker.
- “Order” Service: Manages the entire process from order creation to delivery. This service tracks order status and payment information in its own database.
- “Account” Service: Handles login, registration, and security of customer information. User data is securely stored and shared with other services as needed.
- “Search” Service: Helps users find products quickly. The system optimizes search speed by indexing and temporarily storing data.
All services are connected via:
- Gateway: The entry point that routes user requests to the correct service.
- Message Broker: Ensures consistent communication between services.
Each service has its own database and operates independently, creating a flexible and scalable system.
6. Serverless with AWS Lambda
Serverless Service: Automatic Image Processing for E-commerce Platforms
Image illustrating Serverless image processing for e-commerce websites.
Step 1: User uploads an image to S3 (Amazon’s storage service): The user or another system uploads the image to an S3 bucket.
Step 2: S3 sends an event notification: After the image is uploaded, S3 triggers SNS to send notifications to other services.
Step 3: Lambda is triggered:
- SNS triggers the Lambda function.
- Lambda processes the image, e.g., resizing, compressing, or converting formats.
Step 4: Save the processed image back to S3: The processed image is saved to another S3 bucket.
Step 5: Monitor logs in CloudWatch: Processing and errors (if any) are logged in CloudWatch Logs for monitoring.
7. Microservices and Serverless: Solutions for Vietnamese Businesses.
In the context of digital transformation in Vietnam, many businesses are facing the challenge of scaling their systems to handle peak demand. For example, e-commerce platforms during major sales events (e.g., the upcoming 12/12), delivery applications during rush hours, or digital banking apps at the end of the month. To address these issues, many large enterprises have adopted Microservices architecture and Serverless technology to enhance flexibility, scalability, and performance optimization.
7.1. VNG Cloud
VNG Cloud, with its experience in technology, has applied:
- Kubernetes to manage and orchestrate containers, optimizing system resources and ensuring stability for applications.
- Microservices to deploy small, independent services on their gaming platform, increasing scalability and improving feature deployment time.
- Serverless for tasks like sending notifications, allowing the system to auto-scale as needed and reduce operational costs.
7.2. MoMo
The MoMo e-wallet is a prime example of how Microservices are applied in the financial sector. Their system includes services such as:
- Payment Service: Handles transactions, ensures user accounts have sufficient balance before processing payments, and records transaction information.
- User Authentication Service: Ensures login information and security.
- Transaction Processing Service: Manages the entire transaction process smoothly, ensuring accuracy and safety.
- Promotion Service: Provides customized promotions based on user needs.
The MoMo Microservices system allows services to operate independently while effectively linking together. This not only improves performance but also allows for easy maintenance and upgrades of individual system parts.
8. Conclusion
Microservices and Serverless are like the “modern fairy tales” of the software industry and are becoming a popular choice for businesses embracing digital transformation in Vietnam:
- Solves many problems of Monolithic.
- Cost-saving, performance-boosting.
- Trending future technologies (currently very popular 😉).
- Scales systems flexibly.
- Optimizes operational costs.
- Accelerates product development speed.
Advice for Vietnamese Businesses:
- Start with small independent services.
- Use managed services to reduce operational costs.
- Invest in CI/CD and monitoring from the start.
- Consider the costs and benefits before applying.
Source: GitHub – miztiik/serverless-image-processor: Process images uploaded to S3 using lambda services 🎓
![]() | Hồ Nguyễn Văn Nhật Developer |