I'm planning on transfer an application from Heroku to AWS Elastic Beanstalk. On the Heroku, I have two different applications, one for staging and the other for production, and both have their web and workers dynos.
I'd like to setup something like that on AWS EB. I've read the difference about Web Tier and Worker Tier, but here goes some questions:
Do I setup two different applications for production and staging? Or the same application and two different environments? If so, I would have to create 4 environments, two for production web/worker and two for staging web/worker? What's the correct structure? I'll use the same Rails application for web and worker. In that case, will I have to deploy them separate or is there a command to deploy both environments together?
In AWS Elastic Beanstalk, you can create a load-balanced, scalable environment or a single-instance environment. The type of environment that you require depends on the application that you deploy.
The most important difference in my opinion is that worker tier instances do not run web server processes (apache, nginx, etc). As such, they do not directly respond to customer requests. Instead, they can be used to offload long-running processes from your web tier. The tiers communicate with each other via SQS.
I'll use the same Rails application for web and worker.
This tells me that you should have a single application. Applications manage application versions, which is basically just deployment history.
You will want to create 4 environments. This allows you to "promote to prod" by cname swapping, or by deploying a previously deployed version.
You will have to deploy your web/worker separately, but you could very easily create a script that deploys to both at the same time.
For future reference, AWS Elastic Beanstalk later has created a solution for that called Environment Links:
https://aws.amazon.com/about-aws/whats-new/2015/11/aws-elastic-beanstalk-adds-support-for-environment-links/
With that feature, we're now able to link both environments with the same code (so we deploy it only once instead of twice). To make the worker run the worker process and the web to run the web server, you can set different environment variables and customize the EB initialization scripts to check for those vars and run specific process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With