20
Simple Odoo ERP auto scaling on AWS The Solution Architecture Summary Odoo is an open source business solution software that is suitable for SMEs. Small businesses primarily deploy Odoo on premise. And over the time, this “on premise” deployment can be a challenge because it does not give them a highly available, cost-efficient, fault-tolerant and scalable system. The purpose of this paper is to demonstrate that it is possible to have an Odoo deployment that costs less than $100/month for 50 concurrent users. Moreover, this system will be always available and fault-tolerant and very much scalable. All this, because of its cloud architecture. Note: This document is a working in progress because my intention is to make Odoo as “stateless” as possible. Objectives: Being able to build a highly available and cost- efficient, fault tolerant and highly scalable system. What is the use of Odoo? Odoo (formerly known as OpenERP and before that, TinyERP) is a suite of enterprise management applications. Targeting companies of all sizes, the application suite includes billing, accounting, manufacturing, purchasing, warehouse management, and project management. (ref: https://en.wikipedia.org

Simple Odoo ERP auto scaling on AWS

Embed Size (px)

Citation preview

Page 1: Simple Odoo ERP auto scaling on AWS

Simple Odoo ERP auto scaling on AWS The Solution Architecture

SummaryOdoo is an open source business solution software that is suitable for SMEs. Small businesses primarily deploy Odoo on premise. And over the time, this “on premise” deployment can be a challenge because it does not give them a highly available, cost-efficient, fault-tolerant and scalable system. The purpose of this paper is to demonstrate that it is possible to have an Odoo deployment that costs less than $100/month for 50 concurrent users. Moreover, this system will be always available and fault-tolerant and very much scalable. All this, because of its cloud architecture.

Note: This document is a working in progress because my intention is to make Odoo as “stateless” as possible.

Objectives: Being able to build a highly available and cost-efficient, fault tolerant and highly scalable system.

What is the use of Odoo?Odoo (formerly known as OpenERP and before that, TinyERP) is a suite of enterprise management applications. Targeting companies of all sizes, the application suite includes billing, accounting, manufacturing, purchasing, warehouse management, and project management. (ref: https://en.wikipedia.org /wiki/Odoo ).We are going to use the Odoo version 10 community edition for this demo.

Audience for this document This is document is meant for:

- Students - Small businesses. - Solution Architect - Odoo implementers

Page 2: Simple Odoo ERP auto scaling on AWS

About the architecture principle use in this documentThis document is meant to be simplistic, for this reason we decided to only show few architectural viewpoints. And we also skip some steps that are out of the scoop of this document. Especially the VPC and the general networking configuration that are necessary before you can deploy such system. This document also skipped the provisioning of the RDS system because there are plenty of literature available for the Postgres SQL deployment on AWS.

Solution Architecture design pattern: Auto Scaling viewpoint We design a solution architecture to be simple and readable. And to achieve that, we show a solution architecture design pattern into several viewports. The diagram below shows the Auto scaling viewpoint diagram. This viewpoint neither requires us to show the virtual private cloud network viewpoint diagram nor the security viewpoint diagram.

A good solution architecture design pattern should be simple and concise in its scope. This is what we tried to do here by only showing the Auto Scaling viewpoint.

Page 3: Simple Odoo ERP auto scaling on AWS

What makes this system highly scalable, fault tolerant and cost-efficient?This system is highly scalable because we are using the AWS auto scaling capabilities to allow this system to scale out (increase the number of instances (nodes)) or to scale in (remove the number of nodes) very rapidly.

The system is fault tolerant because the auto scaling configuration comes with health check features that allow your Odoo infrastructure to be resilient.

It is cost-efficient because provisioning your system with “t2.micro” instances is very cheap and moreover they scale gracefully.

Deployment workflow

For the scope of this document we will skip the following steps and link to documentations that can allow the users to successfully deploy or implement those steps:

- AWS: to create an AWS account go to https://aws.amazon.com to create an AWS account

- AWS IAM: read more about this here https://aws.amazon.com/iam/ - AWS VPC: read more here https://aws.amazon.com/vpc/

AWS Create AWS accountSetting up billing

IAMcreate user and roles set up AWS S3 and AWS EC2 policies

VPCset up VPC set up route and internet gatewayset up subnets into at least 2 availabity zone

Postgres RDSInstall Postgres RDS on Multiple AZ Create the Odoo user

Odoo AMIInstall OdooConfigure OdooInstall AWS CLIRemove Postgres SQLInstall NgnixConfigure Odoo port rewrite on Nginx

Auto ScalingCreate an auto scaling configurationCreate an auto scaling group

ELBset up Elastics Load balancing service

Route 53Register a domain Link the ELB to the Route 53 domain

Page 4: Simple Odoo ERP auto scaling on AWS

- AWS RDS: read more here https://aws.amazon.com/rds/ - AWS elastic load balancing https://aws.amazon.com/elasticloadbalancing/ - AWS Route 53 https://aws.amazon.com/route53/

In this document, we will only focus on what is not available out there.

Create an Odoo AMIWhat is an AMI? According to Wikipedia, “An Amazon Machine Image (AMI) is a special type of virtual appliance that is used to create a virtual machine within the Amazon Elastic Compute Cloud ("EC2").” (ref: https://en.wikipedia.org/wiki/Amazon_Machine_Image).

Install AWS Command Line interfaceapt install awscli -y

Install Odoowget -O - https://nightly.odoo.com/odoo.key | apt-key add -

echo "deb https://nightly.odoo.com/10.0/nightly/deb/ ./" >> /etc/apt/sources.list.d/odoo.list

apt-get up1date && apt-get install odoo -y

service Odoo stop

Configure Odoo You can use the odoo configuration file below , just copy& paste the commands below but replace db_host with the Postgres SQL RDS endopoint :

[options]

; This is the password that allows database operations:

; admin_passwd = admin

db_host = your.aws.rds.endpoint.url

; db_port: the database port is 5432

db_port = 5432

db_user = odoo

Page 5: Simple Odoo ERP auto scaling on AWS

db_password = $your.odoo.rds.user.password$

addons_path = /usr/lib/python2.7/dist-packages/odoo/addons

Remove Postgres SQLNow that we have configured Odoo, we will remove the Postgres sql database that comes with the Odoo nightly package.

apt-get autoremove postgresql -y

service postgresql stop

apt-get update -y

Install Nginx What is Nginx? NGINX is an open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It started out as a web server designed for maximum performance and stability. In addition to its HTTP server capabilities, NGINX can also function as a proxy server for email (IMAP, POP3, and SMTP) and a reverse proxy and load balancer for HTTP, TCP, and UDP servers. (Ref: https://www.nginx.com/resources/glossary/nginx/ )

To install Nginx, you can use the following script:

apt-get install nginx -y

Configure Odoo port rewrite with NginxWhen you install Odoo, it runs on port 8069 by default. That can be a little bit annoying especially because few people are aware that you can add a port number after you type a weblink. Moreover, it is more convenient.

Let’s configure Odoo port rewrite. To do this, we should go to the sites-available using the following path and command:

But before this let’s stop Nginx

service nginx stop

and now let’s go to the “sites-available” directory

cd /etc/nginx/sites-available/

Page 6: Simple Odoo ERP auto scaling on AWS

Here, we will create a new file called Odoo and later we’ll link this file to the site-enabled directory using the commands below

Create the Odoo file sudo nano odoo

now copy and paste the code below. You don’t need to change anything because Nginx is really looking at the original port that is port 8069 and the redirect port or listening port that is port 80

server {

listen 80;

server_name example.com;

location / {

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header Host $http_host;

proxy_pass http://127.0.0.1:8069;

}

}

Then hit the following command to save the file and return to the CLI or command line interface.

Ctrl + o and enter then Ctrl + x

ln -s /etc/nginx/sites-available/odoo /etc/nginx/sites-enabled/odoo

The “sites-available” directory contains a file called “default”. We need to delete it now.

rm default

rm /etc/nginx/sites-enabled/default

After this, we will update our Ubuntu server using our apt-get update command

apt-get update -y

Page 7: Simple Odoo ERP auto scaling on AWS

We can now start Odoo and Nginx

service odoo start

service nginx start

This marks the end of the initial setup.

Odoo Initial deploymentIn the previous section, we have setup the Odoo server. In this section, we will do the initial deployment of the Odoo application. We will access the Odoo application through the browser.

Let’s go back to the console and copy the DNS address of our ec2 instance and then paste it into our web browser. If everything goes well, you will see the screen below.

Page 8: Simple Odoo ERP auto scaling on AWS

At this stage just enter the name of the first database. For this demo, we will use the name “demo” and deploy Odoo with the demo data.

Page 9: Simple Odoo ERP auto scaling on AWS

If everything goes well, you will see the screen below:

Page 10: Simple Odoo ERP auto scaling on AWS

Create an AMI images With the steps taken above, we can now create our Odoo AMI. This machine image will allow us to create new Odoo instances.

To create a machine, go to the EC2 dashboard > Select your newly created Odoo instance . Then go to Action >Image> Create Image as shown below

We will use the auto scaling group and the newly created AMI to launch a second instance in the other Availability Zone.

Page 11: Simple Odoo ERP auto scaling on AWS

Auto Scaling configuration Per Amazon “Auto Scaling helps you maintain application availability and allows you to scale your Amazon EC2 capacity up or down automatically according to conditions you define. You can use Auto Scaling to help ensure that you are running your desired number of Amazon EC2 instances. Auto Scaling can also automatically increase the number of Amazon EC2 instances during demand spikes to maintain performance and decrease capacity during lulls to reduce costs. Auto Scaling is well suited both for applications that have stable demand patterns or that experience hourly, daily, or weekly variability in usage” (ref: https://aws.amazon.com/autoscaling/ )

Create the auto scaling groupGo to Ec2>> Auto scaling >> launch configuration

Click on the “Create Auto Scaling group” button

Next, click on the “create launch configuration” button to create a launch configuration group. In the next screen, select the tab called “My AMIs”.

Page 12: Simple Odoo ERP auto scaling on AWS

Here, we will select the Odoo AMI that we have previously taken the snapshot of.

On

At the instance type selection step, we will select an instance type t2.micro because our main goal is to save cost and take advantage of the highly available and highly scalable AWS infrastructures. Let’s click on the “Next: Configuration details” to continue

Page 13: Simple Odoo ERP auto scaling on AWS

Now we will name our launch configuration and select an AWS IAM role that have read right on S3. Continue to the next step and then select your security group.

Select a security group that allows a public internet access on port 80, the. clicked on the “Create launch configuration” button.

Page 14: Simple Odoo ERP auto scaling on AWS

The final step is to create an Auto Scaling group and configure the auto scaling policies. There are other steps, in this section, such as configure the notification and then configure the tags before we can review everything. But we will skip these steps as they are not necessary for this simple demo.

Page 15: Simple Odoo ERP auto scaling on AWS

The Auto scaling policies are instructions given to the Auto Scaling group to launch or kills instances based on certain criteria. Here we have decided to increase the number of instance by 1 one whenever the average CPU usage reaches 60% and decreases by 1 when that average is below 60%of the CPU usage.

Page 16: Simple Odoo ERP auto scaling on AWS
Page 17: Simple Odoo ERP auto scaling on AWS

If everything goes well, as the auto scaling group is created, you can see the EC2 dashboard that the auto scaling group will a new instance.

This is the mark the end of the auto scaling configuration