bookmark_borderAllocate memory to work as swap space on VMs

When physical RAM is already in use, VM instances use swap space as a short-term replacement for physical RAM.

Contents of RAM that aren’t in active use or that aren’t needed as urgently as other data or instructions can be temporarily paged to a swap file. This frees up RAM for more immediate use.


Calculate the swap space size

As a general rule, calculate swap space according to the following:

Amount of physical RAMRecommended swap space
2 GB of RAM or less2x the amount of RAM but never less than 32 MB
More than 2 GB of RAM but less than 32 GB4 GB + (RAM – 2 GB)
32 GB of RAM or more1x the amount of RAM
Note: Swap space should never be less than 32 MB.

In this example dd command, the swap file is 4 GB (128 MB x 32):  

$ sudo dd if=/dev/zero of=/swapfile bs=128M count=32

2.    Update the read and write permissions for the swap file:

$ sudo chmod 600 /swapfile

3.    Set up a Linux swap area:

$ sudo mkswap /swapfile

4.    Make the swap file available for immediate use by adding the swap file to swap space:  

$ sudo swapon /swapfile

5.    Verify that the procedure was successful:

$ sudo swapon -s

6.    Enable the swap file at boot time by editing the /etc/fstab file.

Open the file in the editor:

$ sudo nano /etc/fstab

Add the following new line at the end of the file, save the file, and then exit:

/swapfile swap swap defaults 0 0

Done )

run $ htop and check swp [ ] section.

bookmark_borderINSTALL AND RUN FLASK(PYTHON) ON UBUNTU 19.04 on VpsServer

Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. It began as a simple wrapper around Werkzeug and Jinja and has become one of the most popular Python web application frameworks.

Step #0:
Signup (I appreciate if you use my referral link)
after your account becomes verified, create a Ubuntu 19.04 server.

Step #1:
Install python pip and flask by run:
$ sudo apt install python-pip
$ sudo apt install python3-pip
$ pip install -U Flask
$ pip3 install -U Flask

Step #2:
Add your project files on the server (ex. from GitHub using clone command)
in this tutorial let’s use a very simple flask app example that prints Hello, World! and save the app in (ex. /var/www/flask):

$ mkdir /var/www/flask
$ cd /var/www/flask
$ nano
copy below code and paste it in file using CTRL + SHIFT + V keys.

# file

from flask import Flask

app = Flask(__name__)

def hello():
    return "Hello, World!"

then press ( CTRL+ X )-> Y -> ENTER.

Step #3:
Run the server by run:
$ env flask run -h
change to your server ip


Serving Flask app ""
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on (Press CTRL+C to quit)