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.
Getting Real with AI - Columbus DAW - May 2024 - Nick Woo from AlignAI
Simple Odoo ERP auto scaling on AWS
1. Simple Odoo ERP auto scaling on AWS
The Solution Architecture
Summary
Odoo is an open sourcebusiness solution softwarethat 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 purposeof this
paper is to demonstratethat it is possibleto havean Odoo deployment that costs
less than $100/month for 50 concurrentusers. Moreover, this systemwill 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 becausemy 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 beforethat, TinyERP) is a suite of
enterprise management applications. Targeting companies of all sizes, the
application suite includes billing, accounting, manufacturing, purchasing,
warehousemanagement, 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 documentis meant for:
- Students
- Small businesses.
- Solution Architect
- Odoo implementers
2. About the architecture principle use in this document
This document is meant to be simplistic, for this reason we decided to only show
few architecturalviewpoints. And we also skip some steps that are out of the
scoop of this document. Especially the VPCand the general networking
configuration that arenecessary beforeyou can deploy such system.
This document also skipped the provisioning of the RDS systembecausethere 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
diagrambelow shows the Auto scaling viewpoint diagram. This viewpointneither
requires us to show the virtual privatecloud network viewpoint diagramnor the
security viewpoint diagram.
A good solution architecture design pattern should be simple and concise in its
scope. This is whatwe tried to do here by only showing the Auto Scaling
viewpoint.
3. What makes this system highly scalable, fault tolerant and cost-
efficient?
This systemis highly scalable because weare using the AWS auto scaling
capabilities to allow this systemto scale out (increasethe number of instances
(nodes)) or to scale in (remove the number of nodes) very rapidly.
The systemis fault tolerant becausethe auto scaling configuration comes with
health check features that allow your Odoo infrastructureto be resilient.
Itis cost-efficient becauseprovisioning your systemwith “t2.micro” instances is
very cheap and moreover they scale gracefully.
Deployment workflow
For the scopeof 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 moreabout this here https://aws.amazon.com/iam/
- AWS VPC: read more here https://aws.amazon.com/vpc/
AWS
• Create AWS
account
• Setting up
billing
IAM
• create user
and roles
• set up AWS S3
and AWS EC2
policies
VPC
• set up VPC
• set up route
and internet
gateway
• set up subnets
into at least 2
availabity zone
Postgres RDS
• Install Postgres
RDS on
Multiple AZ
• Create the
Odoo user
Odoo AMI
• Install Odoo
• Configure
Odoo
• Install AWS CLI
• Remove
Postgres SQL
• Install Ngnix
• Configure
Odoo port
rewrite on
Nginx
Auto Scaling
• Create an auto
scaling
configuration
• Create an auto
scaling group
ELB
• set up Elastics
Load balancing
service
Route 53
• Register a
domain
• Link the ELB to
the Route 53
domain
4. - 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 whatis not available out there.
Create an Odoo AMI
What is an AMI? According to Wikipedia, “An AmazonMachine Image (AMI) is a
special type of virtual appliance that is used to create a virtualmachine within
the Amazon Elastic Compute Cloud ("EC2").” (ref:
https://en.wikipedia.org/wiki/Amazon_Machine_Image).
InstallAWS Command Line interface
apt install awscli -y
InstallOdoo
wget-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-getup1date && apt-getinstall odoo -y
service Odoo stop
ConfigureOdoo
You can usethe odoo configuration file below , justcopy& paste the commands
below but replace db_host with the Postgres SQL RDS endopoint :
[options]
; This is the password thatallows database operations:
; admin_passwd = admin
db_host= your.aws.rds.endpoint.url
; db_port: the database portis 5432
db_port= 5432
db_user = odoo
5. db_password =$your.odoo.rds.user.password$
addons_path =/usr/lib/python2.7/dist-packages/odoo/addons
Remove Postgres SQL
Now that we have configured Odoo, wewill removethe Postgres sqldatabase
that comes with the Odoo nightly package.
apt-getautoremove postgresql -y
service postgresqlstop
apt-getupdate -y
InstallNginx
What is Nginx? NGINX is an open sourcesoftwarefor web serving, reverse
proxying, caching, load balancing, media streaming, and more. Itstarted out as a
web server designed for maximum performanceand stability. In addition to its
HTTP server capabilities, NGINX can also function as a proxy server for email
(IMAP, POP3, and SMTP) and a reverseproxy and load balancer for HTTP, TCP,
and UDP servers. (Ref: https://www.nginx.com/resources/glossary/nginx/ )
To install Nginx, you can usethe following script:
apt-getinstall nginx -y
ConfigureOdoo port rewrite with Nginx
When you install Odoo, it runs on port8069 by default. That can be a little bit
annoying especially because few people are awarethat you can add a port
number after you type a weblink. Moreover, it is more convenient.
Let’s configureOdoo port rewrite. To do this, weshould 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/
6. Here, wewill 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 portthat is port8069 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 savethe 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, wewill update our Ubuntu server using our apt-get update command
apt-getupdate -y
7. We can now start Odoo and Nginx
service odoo start
service nginx start
This marks the end of the initial setup.
Odoo Initial deployment
In 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 consoleand 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.
8. At this stage justenter the name of the firstdatabase. For this demo, we will use
the name “demo” and deploy Odoo with the demo data.
10. 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 usethe auto scaling group and the newly created AMI to launch a second
instance in the other Availability Zone.
11. 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 useAuto Scaling to help ensurethat 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 performanceand 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 group
Go to Ec2>> Autoscaling >> launch configuration
Click on the “Create AutoScaling group” button
Next, click on the “create launchconfiguration” button to create a launch
configuration group. In the next screen, select the tab called “My AMIs”.
12. Here, wewill select the Odoo AMI that we have previously taken the snapshotof.
On
At the instance type selection step, we will select an instancetype t2.micro
because our main goal is to save costand take advantage of the highly available
and highly scalable AWS infrastructures. Let’s click on the “Next: Configuration
details” to continue
13. Now we will name our launch configuration and select an AWS IAMrole 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 port80, the. clicked
on the “Create launchconfiguration” button.
14. The final step is to create an Auto Scaling group and configurethe auto scaling
policies. There are other steps, in this section, such as configurethe notification
and then configurethe tags before we can review everything. But wewill skip
these steps as they are not necessary for this simple demo.
15. The Auto scaling policies are instructions given to the Auto Scaling group to
launch or kills instances based on certain criteria. Here we havedecided to
increase the number of instance by 1 one whenever the average CPUusage
reaches 60% and decreases by 1 when that averageis below 60%of theCPU
usage.
16.
17. 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
Thank you
Julien LECADOU
lecadou@gmail.com