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

Minimal Email Receiving

May 1, 2018


How we receive email for our domain using email forwarding on Amazon SES, with minimum effort. Our web-app sends emails no problem, but we also want to receive emails into the same accounts. For example our web-app sends an automatic email from info@mySite.com, but if it receives an email sent to info@mySite.com, we want to handle that too. The simplest way is to implement email forwarding. (The hard way would be to build an email client inside our web-app, then decide how and when to notify whoever needs to handle it). ... 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

Rails Active Storage: Uploading files to Amazon S3

March 20, 2018


How we used Rails Active Storage and got it working with Amazon S3. If you are new to Active Storage, here are a couple of useful links: A great video introduction to Active Storage: File uploading with ActiveStorage in Rails 5.2 A useful overview on creating your bucket on Amazon S3: Tutorial: How to use Amazon S3 and CloudFront CDN to serve images fast and cheap For our use case we are uploading PDF documents direct to the cloud. ... 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 responding and 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 failing with no clues in the logs. We were unsure if the memory issue was with this AWS instance or this update. ... 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. 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

© 2018 Keith P | Follow on Twitter | Git