Fixing a Memory-bottlenecked Rails App

July 2, 2018


On Jun 29 Nate Berkopec (@nateberkopec) tweeted this: “Observation: when scaling on AWS/AWS-based VPS services, newer, lower-volume Rails applications tend to be memory-bottlenecked, older, high-volume Rails applications tend to be cpu-bottlenecked.” This is really useful to know. We recently saw our tiny new Rails app running on an AWS t2.micro server getting into a “WARN” state after running a sucker punch job. It was using over 90% of its RAM, and stayed that way until we restarted the server. ... Read more

Rails 5.2: encrypted secrets

March 22, 2018


How we started to use Rails 5.2 Encrypted Secrets for securing Amazon S3 key pairs for use with Active Storage. Here is a useful starting point: Rails Encrypted Credentials on Rails 5.2 Our development and production envionment is Linux, and we precompile our assets before deployment. Part 1: Encrypt your secrets With Rails 5.2 a sort of ‘password safe’ is introduced, whereby you commit your encrypted secret credentials to source control, but not your master password. ... Read more

Let’s Encrypt automatic SSL certificate renewal on a single AWS instance

August 14, 2017


How we configured Elastic Beanstalk to play nicely with automatic certificate renewal by Let’s Encrypt. Everyone it seems is going with Let’s Encrypt to generate their free SSL/TLS ceritficate. Running it once is easy, but getting it configured to work with Elastic Beanstalk and EC2’s lifecycle can send you round in circles. This post is an update of the original January 2017 post with our improved configuration. The configuration needs to cater for ALL of these scenarios: ... Read more

Rails 5 tutorial chat app - can we deploy it to AWS?

December 30, 2015


The simple chat example that DHH built in his recent screencast using ActionCable in Rails 5, is available on GitHub here: https://github.com/HectorPerez/chat-in-rails5. But can we get this working on an Elastic Beanstalk single instance - with no load balancer ? => Initially yes, then no, then yes! On a development pc:Action Cable works with redis so to run the chat app you will need to install redis on your local machine: ... Read more

Upgrading to Rails 5.0.0.beta1

December 21, 2015


What we did to upgrade a small Rails app from Rails 4.2.5 to Rails 5.0.0.beta1. Now the upgrade is deployed in AWS, here is where we are at: When deploying, remember to change the secret key base to invalidate all sessions. ( or your users will get a nasty 500 error ) Temporarily removed NewRelic from the gemfile – it doesn’t currently support Rails 5.0.0.beta1. (UPDATE: as of 11 Feb NewRelic supports Rails 5. ... Read more

Scaling down to single instance Elastic Beanstalk.

April 13, 2015


When you are looking to reduce your AWS costs, you might consider removing the Load balancer. At $20 per month it accounts for a large proportion of the hosting costs for a small application. Is it really needed right now? Down the line when your application grows, you can easily bring it back - right? Elastic beanstalk is handy for provisioning and deployment, and thankfully the load balancer is not compulsory. ... Read more

Rails 4.2.1 upgrade ( SMTP email sending fail)

March 27, 2015


Soon after we updated to Rails 4.2.1 from 4.2.0 deployed - the site stopped respondingand we saw this error in the passenger log: phusion_passenger/preloader_shared_helpers.rb:69:in `fork': Cannot allocate memory - fork That was also the last time emails were successfully sent from Elastic Beanstalk. Now SMPT emails are silently failingwith no clues in the logs. We were unsure if the memory issue was with this AWS instance or this update. Later decided it was the instance. ... Read more

Moving Rails development from Windows to Linux

February 23, 2015


Recently we embarked on a new feature requiring a gem that is not compatible with Windows. see also: [Moving Rails Development to Windows WSL 2 Linux] (/post/moving-rails-development-to-windows-wsl2-linux/). To re-quote a quote from https://meta.discourse.org/t/bundle-install-fails-on-windows/6494 : “The reality is that Ruby, as used by most Rails apps is full of unixism, performance of Ruby MRI (the default Ruby) on Windows is abysmal, Rails load times are hellish, sooner or later (more likely sooner) you are going to hit gems that simply do not work properly on Windows. ... Read more

Configuring HTTPS for the AWS Elastic Beanstalk Load balancer

January 19, 2015


Switching your Rails site to always use HTTPS takes a bit configuring. Here is how we followed AWS’s 3 high level steps: http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/ssl-server-cert.html Create a custom domain with your DNS provider. Create and upload an SSL certificate to AWS Identity and Access Management (AWS IAM). Update your Elastic Beanstalk environment to use HTTPS. Step 1) was DONE - We already had our own www.ourdomain.com, not registered on AWS route 53 nor using the AWS route 53 name servers, but with godaddy. ... Read more

© 2020 Keith P | Follow on Twitter | Git