The development was done in-house using Ruby on rails (v2.3) and the server requirements for running the monolith application were very high. Being a financial company downtime of the application is not acceptable. The standard approach to put the application under a load balancer to multiple servers was not possible as this could introduce race conditions where the same transaction is paid out multiple times. The wallets for crypto currencies were hosted on machines and communicated over open APIs introducing security concerns. The company was paying more than fifteen thousand USD to AWS. This was a cost that needed to be reduced.
The request from the customer was to
We introduced multiple solutions for meeting the challenges of the client.
Increase reliability of the service/Application
We split the application into multiple services and introduced a RabbitMQ for queuing services. All inter-application services communicate using dedicated channels on RabbitMQ. For handling the issue of race conditions, we set up timed single-use signatures computed using API Secret. Using this method the correspondents utilizing the services encrypted the payload using the secret key. This protected the application from replay attacks as well as accidental/malicious API requests hitting the platform. Now even if multiple services are up, one message on the queue will only be processed by one instance of the application.
Have Zero downtime
With the introduction of micro services and the single-use API post, we were able to deploy the services to Amazon Container Services and have a self-healing infrastructure. This also enabled us to have blue-green deployments which in turn enabled us to provide zero downtime for application upgrades. We also leveraged vercel.com to host the front-end code of the application. To increase the speed of the API responses we introduced AWS Global Accelerator.
Reduce cost
We moved the application from EC2 instances to ECS services, the only service that is now running on a dedicated host is RabbitMQ. The rest of the services we containerized including the cryptocurrency wallet services and the blockchain was mounted on S3 using FUSE filesystem. By updating the application and moving to container technologies we were able to bring down the AWS costs from fifteen thousand US$ to three thousand US$.
By making the changes in the application and introducing new technologies were able to meet all expectations of the client. There are many improvements that the client saw with the new architecture other than the requirements mentioned. Lower response times to API requests have enabled the client to accept and process more transactions than before. The cost of implementing the changes will be re-couped by the client with 12 months of going live with the new architecture from the reduced AWS spends alone.
Tool Set