Understanding Linux Load Average – Part 1

Very nice article on how to detect load average issue

The Dutch Prutser's Blog

A frequently asked question in my classroom is “What is the meaning of load average and when is it too high?”. This may sound like an easy question, and I really thought it was, but recently I discovered that things aren’t always that easy as they seem. In this first of a three-part post I will explain what the meaning of Linux load average is and how to diagnose load averages that may seem too high.

Obtaining the current load average is very simple by issuing the uptime command:

But what is the meaning of these 3 numbers? Basically load average is the run-queue utilization averaged over the last minute, the last 5 minutes and the last 15 minutes. The run-queue is a list of processes waiting for a resource to become available inside the Linux operating system. The example above indicates that on average there were 10.52 processes waiting…

View original post 836 more words

Understanding Linux Load Average – Part 1

Serving Flask with nginx

Installing Common Python Tools for Deployment
:
apt-get install -y python python-dev python-distribute python-pip
apt-get install nginx

Installing The Web Application and Its Dependencies
Download and install Flask and uwsgi using pip

pip install virtualenv
mkdir /var/www/ngstones.com && cd /var/www/ngstones.com
virtualenv -p /usr/bin/python venv
source venv/bin/activate
pip install uwsgi
pip install flask

rm /etc/nginx/conf.d/default

vim /etc/nginx/conf.d/ngstones

server {
listen 80;
server_name 10.0.0.2;
charset utf-8;
client_max_body_size 75M;

location / { try_files $uri @ngstones; }
location @ngstones {
include uwsgi_params;
uwsgi_pass unix:/var/www/ngstones.com/demoapp_uwsgi.sock;
}
}

vim /var/www/ngstones.com/demoapp_uwsgi.ini

[uwsgi]
#application's base folder
base = /var/www/ngstones.com

#python module to import
app = hello
module = %(app)

home = %(base)/venv
pythonpath = %(base)

#socket file’s location
socket = /var/www/ngstones.com/%n.sock

#permissions for the socket file
chmod-socket = 666

#the variable that holds a flask application inside the module imported at line #6
callable = app

#location of log files
logto = /var/log/uwsgi/%n.log

vim /var/www/ngstones.com/hello.py
from flask import Flask
app = Flask(__name__)
@app.route(“/”)
def hello():
return “Hello!”
if __name__ == “__main__”:
app.run()

Restart Nginx to load new config file
service nginx restart
cd /var/www/ngstones.com/
uwsgi --ini /var/www/ngstones.com/demoapp_uwsgi.ini

Finally update your DNS and you are good to go!

Serving Flask with nginx