View All Posts
read
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
#ELASTIC BEANSTALK #GEM DEPENDENCIES #MEMORY ISSUES #NATIVE EXTENSIONS #SWAP

One thing that you may find when running Elastic Beanstalk on small instances is that you can run out of memory very easily.

This can be particularly troublesome when deploying a real world application to Elastic Beanstalk that depends on gems with native extensions. Building these native extensions can quickly exhaust physical memory and by default ec2 instances do not have any virtual memory (swap) configured.

ERROR: Unsuccessful command execution on instance id(s) 'i-0077ee0ac45e9207a'. Aborting the operation.
ERROR: Failed to deploy application.
ERROR: Failed to deploy application.

Examining the eb activity logs with eb logs reveals the underlying problem:

Cannot allocate memory - /opt/rubies/ruby-2.3.1/bin/ruby -r ./siteconf20170603-17803-rttiu8.rb extconf.rb 2>&1

The machine has run out of physical memory.

To fix this we can add swap to our Elastic Beanstalk instances using the following file:

# .ebextensions/01_setup_swap.config
commands:
  01setup_swap:
    test: test ! -e /var/swapfile
    command: |
      /bin/dd if=/dev/zero of=/var/swapfile bs=1M count=2048
      /bin/chmod 600 /var/swapfile
      /sbin/mkswap /var/swapfile
      /sbin/swapon /var/swapfile

Add this file to git: git add . && git commit -m "adds swap". Now deploy to Elastic Beanstalk and your memory issues should be fixed.

#ELASTIC BEANSTALK #GEM DEPENDENCIES #MEMORY ISSUES #NATIVE EXTENSIONS #SWAP

Related Posts

Step 8: Set up Active Job on Elastic Beanstalk - This blog post walks through setting up a worker environment on Elastic Beanstalk and using SQS as our Active Job queue, using the active-elastic-job Gem. We start by creating a new queue in our AWS account via Simple Queue Service. Then, we provide our Elastic Beanstalk environments access to the queue and add an AWS_REGION environment variable. We proceed to creating and configuring our worker environment. In our Rails app, we instruct Active Job to use our active-elastic-job queue adapter and create an Active Job. Finally, we deploy our changes to both the web and worker environments, ensuring our ActiveJobs run successfully.
Step 2 - Setup Elastic Beanstalk: Deploying a Rails Application to Elastic Beanstalk - In this post, I describe how to set up, configure and deploy an Elastic Beanstalk application on a VPC in Amazon AWS, using Rails 5 and Ruby, using Puma for deployment and configuration of Public and Private subnets in Elastic Load Balancer. I also cover the details of network card settings, the selection process for subnets and security groups for Load Balancer and Instances, and finally shared the result of deploying the sample application on Elastic Beanstalk.
Step 4: Deploy Rails App To Elastic Beanstalk from Command Line - This post guides you through the essential steps of creating and deploying a Rails application into Elastic Beanstalk environment. Topics include creating an AWS user, configuring AWS CLI for deployment, and setting up the environment variables for your app. Also, it provides you the valuable knowledge of connecting your Rails app to RDS instance and ensuring it successfully connects with the dev database.
Step 1 - Setup VPC: Deploying a Rails Application to Elastic Beanstalk - In this blog post, I am guiding you through the process of deploying a Rails application to Elastic Beanstalk in a Virtual Private Cloud (VPC) on Amazon AWS. I detail the setup of a VPC, subnets, and internet gateways, as well as the configuration of NAT gateways and security groups. Ultimately, this will allow for a safe, internet-accessible environment for your application and its accompanying databases.
Step 5: Use CircleCI to Deploy To Elastic Beanstalk - In this blog post, we're going to set up an automated deployment pipeline using CircleCI, GitHub, and AWS Elastic Beanstalk. We'll begin by creating a GitHub repository for our Rails application. Next, we're going to help CircleCI understand our build environment by creating a `circle.yml` file to install the AWS EB CLI tools and to define commands for deploying our application. Lastly, we'll set up the required AWS credentials in CircleCI. Once completed, any changes pushed to the develop or master branch in GitHub will trigger a deployment to the respective environment in Elastic Beanstalk.

Related Videos

The Hacker News Effect - The Website Didn't Catch Fire - Let's look at the traffic - Witness the Hacker News effect in action as the author's blog skyrocketed to popularity, easily handling massive traffic thanks to efficient hosting and Cloudfront!
AR Sudoku Solver in Your Browser: TensorFlow & Image Processing Magic - Discover how to recreate a Sudoku app using browser APIs and ecosystem advancements, and explore the image processing pipeline technique for extracting Sudoku puzzles and solving them.
Mastering ESP32 Deep Sleep: Timers, GPIOs & Touch Sensors Explained - Learn how to put the ESP32 into deep sleep mode to extend the battery life of your IoT projects. This tutorial will cover methods for waking up the ESP32 using timers, GPIO pins, and touch sensors, along with maintaining state during deep sleep.
ESP32 Audio DMA Settings Explained - dma_buf_len and dma_buf_count - Learn how to choose ideal parameters for dma_buf_count and dma_buf_len when working with I2S audio and DMA, exploring the impact of these values on CPU load, latency, and memory usage.
ESP32-TV Version 3 - Is it done? - In today's project update, I'm excited to share that my ESP32-TV boards, fresh from PCBWay, are operating flawlessly! We've successfully dealt with the USB2244 conflict with the ESP32, and the battery charging issue is now a thing of the past. We've also made some awesome additions like a microphone to our board. The real MVP though, is the USB2244 chip that’s given us significantly improved read/write speeds - making it perfect for handling video files. Next on the agenda, figuring out a solution for the non-standard display connector. As ever, there’s progress, there’s problems, and there's David Bowie animated gifs!
HELP SUPPORT MY WORK: If you're feeling flush then please stop by Patreon Or you can make a one off donation via ko-fi
Want to keep up to date with the latest posts and videos? Subscribe to the newsletter
Blog Logo

Chris Greening


Published

> Image

atomic14

A collection of slightly mad projects, instructive/educational videos, and generally interesting stuff. Building projects around the Arduino and ESP32 platforms - we'll be exploring AI, Computer Vision, Audio, 3D Printing - it may get a bit eclectic...

View All Posts