As a software development firm that creates specialised software for many sectors, we have a lot of development, test, and beta servers that must be available during business hours but may be shut down at night. These servers are costly and can eat up a lot of resources.
We planned to utilise EC2 for the following two endeavours:
- First, we had to make sure that the servers only worked during office hours to avoid spending money on things that weren't necessary.
- Second, we had to make sure that the Dev Test and Beta servers were always up and running during business hours to make the development process easier.
The three choices available were manual start/stop, cron job setup, and Amazon Lambda start/stop routines.
Manual start and stop would have been recommended when the start and stop events are not very frequent, and it also causes unnecessary resource engagement. Our second solution, Cron jobs, requires a separate server. It's not cost-effective. Also, a cron job that uses scripts to start and stop remote servers needs plenty of permissions.
The AWS Lambda Start and Stop Function appears to be more practical, requiring only a few line functions to start and stop servers on a predefined schedule. At the same time, it will also be an automated approach where the user only needs to write the function once and start the same process that will later run automatically. Also, Lambda functions are not very costly and are billed based on the frequency of the functions being invoked.
We finally chose to use AWS Lambda functions to start and stop their EC2 servers automatically. We implemented the following steps:
- Step 1: Created a lambda function that would start and stop all of the required servers during business hours.
- Step 2: The Lambda function was triggered at the start of the business day and shut down the servers at the end of the day. This ensured that the servers were only operational during office hours and that the company was not incurring any unnecessary consumption costs.
- Step 3: To ensure that the Dev Test and Beta servers were always up and running during business hours, the company created a separate Lambda function that started these servers earlier than the others.
- Step 4: The second Lambda function was triggered before the start of the business day and ensured that the Dev Test and Beta servers were operational before any development work began.
- Step 5: The Lambda functions were configured to run automatically every day at the specified times, ensuring that the servers were consistently available when required.
The implementation of AWS Lambda functions allowed us to go serverless with cost optimization while ensuring the development, test, and beta servers are up when required with automation.
- Significant reduction in consumption costs as the servers were only operational during business hours.
- Consistent availability of Development Test and Beta servers during business hours, enabling the development team to work efficiently.
- Reduced manual workload for the IT team as the Lambda functions automated the start and stop of the servers.