Overview
MyMoney AB, market leader in unsecured loans, with business in Sweden and Finland, is running their system in the AWS Cloud. Sigma Technology Cloud conducted a Well Architected Review on the workload. In the review potential cost optimization areas was identified. Sigma Technology Cloud assisted MyMoney in an migration to Graviton based CPU for containers and databases, to increase performance and lower cost.
Introduction to AWS Graviton
The AWS Graviton processor, developed by Amazon Web Services (AWS), provides an economical and efficient option for deploying applications in the cloud. Utilizing ARM architecture and 64-bit Neoverse cores, these processors are engineered for peak performance and scalability at minimal cost and latency. Amazon Web Services has tailored the design of Graviton processors to offer optimal price-performance and expandability.
Why migration to Graviton matters
Cost Savings
Utilizing ARM architecture, AWS Graviton instances deliver a cost-effective alternative to traditional x86 instances. They strike an excellent balance between cost and performance, enabling businesses to lower their infrastructure expenses.
Enhanced Performance
AWS Graviton’s reliance on ARM-based processors translates to superior performance and efficiency. Shifting your operations to AWS Graviton can lead to notable improvements in performance, quicker response times, and decreased latency.
Architecture overview
MyMoney is running a Java based microservice architecture running on Elastic Container Service (ECS) with Amazon Aurora MySQL as database. The system consists of around 25 microservices with a varying load, with long periods of low traffic and high spikes. Services in ECS runs in Fargate mode. In an previous migration MyMoney, with help from Sigma Technology Cloud, migrated from an EC2 based ECS cluster to Fargate. This was done to reduce undifferentiated heavy lifting, and let the development team focus on business features instead of patching servers.
CI/CD overview
The CI/CD setup is based on GitHub and GitHub Actions, building the container images and pushing them to ECR. The ECS TaskDefinition if updated with a new image version which will trigger an service update in the corresponding ECS Cluster, Dev, Test, Prod.
Migrating databases
Since the MySQL database was running as a managed service on Amazon Aurora the migrating process to Graviton based instances are not that complicated, but still require a strict process and testing. A process and run-book for the migration was created, which could be followed for each environment. After each environment migration the application was tested and monitored to ensure no problems was found.
Migrating Amazon Aurora to Graviton is as easy as swapping the database instance family. However, to ensure the quality several more steps should be taken.
Detailed upgrade instructions
Create a database snapshot: This step is crucial as it allows you to revert any changes made during the process. Ensure not to overlook this action.
Verify database version compatibility with Graviton.
Make sure your current database version is supported by Graviton2. If not, you’ll need to upgrade. Compatible versions include Aurora MySQL version 2.09.2 or later.
Change the instance types accordingly.
For setups with read replicas. Begin by upgrading a read replica to Graviton, then promote it to the primary instance
Without read replicas, consider adding a read replica temporarily to avoid downtime during the instance upgrade.
Perform a thorough validation. Ensure your application functions as expected. If you’re using performance insights, it can help you analyze query performance and wait times.
Proceed with the migration. If everything checks out, you can migrate your remaining replicas one at a time, ensuring a smooth transition.
These steps should be followed for each environment and if any problems occurs this should be noted down and learnings applied when migrating the next environment.
Migrating ECS
Migration of containers in Fargate, specially Java based containers, is also a fairly straight forward process. The build process need to be adapted to the ARM architecture together with an update of the Fargate runtime. At MyMoney all infrastructure are defined as Infrastructure as Code using CloudFormation. To update the Fargate runtime to be based on Graviton the CpuArchitecture must be set to ARM64 in the RuntimePlatform section of the TaskDefinition.
CloudFormation snippet.
—
ServiceTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
TaskRoleArn: !Ref TaskRole
ExecutionRoleArn: !Ref TaskExecutionRole
RequiresCompatibilities:
– FARGATE
NetworkMode: awsvpc
Cpu: !Ref TaskCpuUnits
Memory: !Ref TaskMemory
RuntimePlatform:
CpuArchitecture: ARM64
ContainerDefinitions:
– Image: ‘….’
Name: !Ref ServiceName
PortMappings:
– ContainerPort: 8080
Protocol: tcp
—
MyMoney use Gradle for building the application, a step that doesn’t change when going to Graviton. When the container image is built this must be built for an ARM based architecture, and since the build is done from an X86 based runner in GitHub Actions, a must be a cross compile done. To do that MyMoney utilize the buildx command in Docker and setting the target platform to linux/arm64. Setting the provenance flag to false ensures there is only a single image created. Without this flag an empty X86 based image would be created and pushed to ECR.
GitHub Actions snippet
– name: Build and push Docker image
env:
REGISTRY: …
REPOSITORY: …
IMAGE_TAG: …
run: |
docker buildx build \
–platform linux/arm64 \
–build-arg JAR_FILE=…. \
–tag $REGISTRY/$REPOSITORY:$IMAGE_TAG \
–push \
–provenance false \
.
With the two combined changes container images are created for Graviton and can be run on a Graviton based Fargate task.
Outcome
The initial measurements show that MyMoney has saved around 25% of the total compute and database cost. The system’s overall performance has increased, CPU utilization is lower than before the migration. This would allow for container tasks to be scaled down which would lead to even more cost savings. Not only does Graviton has the best price performance metric it also consume less energy, which leads to a lower carbon footprint.
About MyMoney AB
MyMoney Europe AB is a credit company with permission from the Financial Supervisory Authority to conduct lending and brokering of credits to households and companies.
We operate a proprietary technology platform that connects retailers, consumers and selected banking partners in a financial ecosystem, with the aim of creating value for all parties.
MyMoney offers Swedish households simple and effective financing for major purchases at attractive terms. We give our selected bank partners access to a flow of loan applications from consumers seeking loans for important investments.
Sigma Technology Cloud – Spotlight
Founded in 2021, Sigma Technology Cloud has quickly emerged as a leading player in cloud services in the Nordics, investing in top talent to drive rapid growth and client success. Sigma Technology Cloud offers end-to-end cloud consulting solutions tailored to organizations of all sizes, leveraging industry expertise and cutting-edge technology to deliver outstanding service.