Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Install and configure Redis on ElasticBeanstalk

How do I install and configure Redis on AWS ElasticBeanstalk? Does anyone know how to write an .ebextension script to accomplish that?

like image 562
Ecil Avatar asked Oct 23 '14 12:10

Ecil


People also ask

Is Elastic Beanstalk good?

Elastic Beanstalk's main benefits include timesaving server configuration, powerful customization, and a cost-effective price point. Elastic Beanstalk automates the setup, configuration, and provisioning of other AWS services like EC2, RDS, and Elastic Load Balancing to create a web service.

Does Elastic Beanstalk support C++?

You can for example bundle your compiled C++ program with all the required libraries together with your PHP code and deploy the same way you deploy the PHP code to Elastic Beanstalk. It can be in the same package or in a separate ZIP file.

What is Elastic Beanstalk com?

AWS Elastic Beanstalk is an easy-to-use service for deploying and scaling web applications and services developed with Java, . NET, PHP, Node. js, Python, Ruby, Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS.


1 Answers

The accepted answer is great if you are using ElastiCache (like RDS, but for Memcached or Redis). But, if what you are trying to do is tell EB to provision Redis into the EC2 instance in which it spins up your app, you want a different config file, something like this gist:

packages: 
  yum:
    gcc-c++: [] 
    make: []
sources:
  /home/ec2-user: http://download.redis.io/releases/redis-2.8.4.tar.gz
commands:
  redis_build:
    command: make
    cwd: /home/ec2-user/redis-2.8.4
  redis_config_001:
    command: sed -i -e "s/daemonize no/daemonize yes/" redis.conf
    cwd: /home/ec2-user/redis-2.8.4
  redis_config_002:
    command: sed -i -e "s/# maxmemory <bytes>/maxmemory 500MB/" redis.conf
    cwd: /home/ec2-user/redis-2.8.4
  redis_config_003:
    command: sed -i -e "s/# maxmemory-policy volatile-lru/maxmemory-policy allkeys-lru/" redis.conf
    cwd: /home/ec2-user/redis-2.8.4
  redis_server:
    command: src/redis-server redis.conf
    cwd: /home/ec2-user/redis-2.8.4

IMPORTANT: The commands are executed in alphabetical order by name, so if you pick different names than redis_build, redis_config_xxx, redis_server, make sure they are such that they execute in the way you expect.

Your other option is to containerize your app with Redis using Docker, then deploy your app as some number of Docker containers, instead of whatever language you wrote it in. Doing that for a Flask app is described here.

You can jam it all into one container and deploy that way, which is easier, but doesn't scale well, or you can use AWS' Elastic Beanstalk multi-container deployments. If you have used docker-compose, you can use this tool to turn a docker-compose.yml into the form AWS wants, Dockerrun.aws.json.

like image 151
Sam H. Avatar answered Sep 18 '22 08:09

Sam H.