Which approach is better to move a microservices application to the cloud? Kubernetes, AWS Lambda, etc. How to choose one?

1/9/2020

I want to start to build a Microservices Application. So far I have identified each project and the way that they interact each other, also the relation with the DB. I am using Java 8, Angular, Spring Boot, Hibernate and PostgreSQL mainly.

Everything is working fine in my local environment! But now I need to move everything to the cloud.

I was thinking in test the app in EC2 free tier on AWS.

  • Deploy a docker container for each microservice with zero-downtime without using Elastic Beanstalk or ECS. (Just testing in free tier)
  • PostgreSQL running local in EC2.

But at the end I need a right approach to do this in the Cloud.

Any idea?

-- Adrien J
amazon-web-services
java
kubernetes
microservices
spring-boot

2 Answers

1/9/2020

Note: this question might belong to Software Engineering.

I will assume you only have the following components:

  • web app
  • Postgresql database

In order to prevent downtime, you should spread traffic across your resources (1) so they're not overloaded and (2) you must have a way to detect when they become unhealthy (unresponsive, CPU too high, etc.).

You can deploy your webapp to EC2 and solve (1) by using an Elastic Load Balancer and (2) by configuring an Auto Scaling Group and its health checks. Since you are using Spring Boot, you can use the Spring Boot Actuator health endpoints.

For your database, I suggest looking into RDS. It offers a managed Postgresql database, this means you don't have to take care of some administrative tasks.

This blog article describes RDS auto scaling: you can use vertical scaling (using a bigger database when needed) or increasing the number of read replicas if your load consists of a lot of reads (SELECTs).

If you have infrequent database traffic, you might be interested in RDS Serverless. This service auto scales automatically and even shuts down when the database is not in use.

The AWS free tier allows you to start EC2 and RDS t2.micro instances.

-- pyb
Source: StackOverflow

1/9/2020

Learning a technology is one thing and using the application for production is another. I am sharing my answer that would cover application for production use.

Choosing service around business needs

Cloud has so many offerings to choose from and could be confusing. I have used Kubernetes and AWS lambda both and I believe services and architecture should be chosen around business needs not because we heard about them. You need to think about usage, availability , scalability and development life cycle of the application. Don't over engineer If an application is not business critical and being used by handful of people you can simply get away deploying it on Elastic beanstalk or lambdas. You don't need Kubernetes . Always try to use manage service than reinventing the wheel.

Lambda vs Kubernetes (k8s)

Lambda and API gateway is a very powerfull choice as long as you know serverless architecture and caveats around it e.g. java cold start time and performance on lambda is not good compared to other languages like Goland, C# , nodejs etc. In my experience most of the time using Lambda could get so such a huge cost benefit that you can get away with free tier. You are lighting quick to deploy your code and you don't worry about availability , scalibility or downtime. It's a great choice for green field projects.

Kubernetes (k8s) Everyone is on the band wagon without realizing if they actually need it. Kubernetes is a very powerful container orchestration but that's a complete new skill and you still have to do the capacity planning and learn lots of moving parts around it. Containers are great choice if you want to package dependencies and want to be cloud agnostic. It's also a good choice if you want to move your legacy apps to cloud or even run legacy with modern apps side by side.

Choosing Data store

Again that should be around business needs. For simple application where you don't need complex reporting and joins you can even use NoSQL like Dynamo db which is way cheaper and easier. But if you have strong relational data then you must be looking at managed services like Aurora (MySQL/Posgres) or AWS RDS. Aurora also offer serverless tier now.

Hope that helps !

-- Imran Arshad
Source: StackOverflow