Ọpọlọ + VPS fun 30 rubles =?

O dara pupọ nigbati gbogbo awọn nkan kekere ti o nilo wa ni ọwọ: pen ti o dara ati iwe akiyesi, ikọwe didan, Asin ti o ni itunu, tọkọtaya awọn okun waya afikun, ati bẹbẹ lọ. Awọn ohun aiṣedeede wọnyi ko fa akiyesi, ṣugbọn ṣafikun itunu si igbesi aye. Itan kanna naa wa pẹlu ọpọlọpọ awọn ohun elo alagbeka ati tabili tabili: fun awọn sikirinisoti gigun, fun idinku iwọn aworan kan, fun iṣiro awọn inawo ti ara ẹni, awọn iwe-itumọ, awọn onitumọ, awọn oluyipada, ati bẹbẹ lọ. Ṣe o ni ọkan? VPS - eyiti o jẹ ilamẹjọ, nigbagbogbo wa ni ọwọ ati mu ọpọlọpọ awọn anfani wa? Rara, kii ṣe ọkan ti o ni ninu ile-iṣẹ rẹ, ṣugbọn tirẹ, “apo” ọkan. A ro pe laisi VPS kekere kan ni ọdun 2019 o jẹ ibanujẹ bakan, gẹgẹ bi laisi ikọwe orisun igbagbogbo ni ikẹkọ kan. Kini idi ti o fi ni ibanujẹ? Igba ooru ni. Bawo ni igba ooru? Ooru fun alamọja IT: joko ni ile, ṣiṣẹ lori awọn iṣẹ akanṣe ayanfẹ rẹ laisi banujẹ eyikeyi. Ni gbogbogbo, a ronu ati ṣe.

Ọpọlọ + VPS fun 30 rubles =?
Communism ti de, awọn ẹlẹgbẹ.

O dabi iyẹn - VPS wa fun ọgbọn

A ti ka ọpọlọpọ awọn nkan lati ọdọ awọn oludije ati awọn olumulo ti o kowe 3-4 ọdun sẹyin nipa idi ti a ko nilo VPS ilamẹjọ. O dara, iyẹn tọ, lẹhinna VPS “fun penny kan” jẹ titaja mimọ ati pe ko le pese awọn aye iṣẹ deede. Ṣugbọn awọn akoko n yipada, idiyele ti awọn orisun foju n dinku ati isalẹ, ati fun 30 rubles fun oṣu kan a ti ṣetan lati funni ni eyi:

  • Ilana: Intel Xeon 2 GHz (1 mojuto)
  • Eto Linux (Debian, Ubuntu, CentOS lati yan lati)
  • 1 ifiṣootọ IPv4 adirẹsi
  • 10 GB ti ibi ipamọ data lori awọn awakọ SSD kilasi ile-iṣẹ iyara
  • Àgbo: 512 MB
  • Fun ìdíyelé keji
  • Unlimited ijabọ

Owo idiyele jẹ koko ọrọ si awọn ihamọ imọ-ẹrọ afikun, awọn alaye lori iwe ipese itura wa - VPS fun 30 rubles. 

Tani olupin foju yii dara fun? Bẹẹni si gbogbo eniyan: awọn olubere, awọn alara, awọn olupilẹṣẹ ti o ni iriri, awọn onijakidijagan DIY ati paapaa awọn ile-iṣẹ kan.

Kini VPS yii dara fun?

A ro pe awọn oluka Habr yoo dajudaju rii ọna tiwọn ti lilo iṣeto yii, ṣugbọn a pinnu lati gba yiyan awọn imọran tiwa - kini ti ẹnikan ba nilo rẹ, ṣugbọn awọn ọkunrin ko mọ?

  • Gbe oju opo wẹẹbu rẹ ti o rọrun, portfolio, bẹrẹ pẹlu koodu, ati bẹbẹ lọ. Nitoribẹẹ, oju opo wẹẹbu ti ara rẹ ṣe apẹrẹ ti o dara lori agbanisiṣẹ. Fi sii lori VPS rẹ ki o jẹ iduro fun aabo ati iduroṣinṣin ti aaye naa funrararẹ, kii ṣe nipasẹ oṣiṣẹ ti awọn olupese alejo gbigba deede.
  • Lo VPS fun awọn idi eto-ẹkọ: gbalejo iṣẹ akanṣe rẹ, ṣe iwadi awọn ẹya ti olupin ati ẹrọ iṣẹ olupin, ṣe idanwo pẹlu DNS, tinker pẹlu aaye eto-ẹkọ kekere kan.
  • Fun tẹlifoonu. Nigba miiran otaja onikaluku, freelancer tabi ile-iṣẹ kekere kan nilo pataki tẹlifoonu IP, ati pe awọn oniṣẹ ti tẹlifoonu yii jẹ ojukokoro pupọ. O rọrun: a mu olupin wa, ra nọmba kan lati ọdọ oniṣẹ tẹlifoonu IP kan, ṣeto PBX foju kan ati ṣẹda awọn nọmba inu (ti o ba jẹ dandan). Awọn ifowopamọ jẹ tobi pupo.
  • Lo olupin lati ṣe idanwo awọn ohun elo rẹ.
  • Lo olupin naa fun awọn idanwo DIY, pẹlu iṣakoso ati gbigba data lati awọn sensọ eto ile ti o gbọn.
  • Ọna dani lati lo ni lati gbe oluranlọwọ iṣowo paṣipaarọ foju kan, robot iṣowo kan, lori olupin naa. Iwọ yoo jẹ iduro ni kikun fun iduroṣinṣin ati aabo olupin, eyiti o tumọ si pe iwọ yoo gba ohun elo iṣakoso fun iṣowo lori awọn ọja iṣura. O dara, ti ẹnikẹni ba nifẹ tabi gbero :)

Awọn ohun elo wa fun iru VPS ni agbegbe ile-iṣẹ. Ni afikun si iṣẹ tẹlifoonu ti a mẹnuba tẹlẹ, o le ṣe ọpọlọpọ awọn nkan ti o nifẹ si. Fun apere:

  • Gbe awọn apoti isura infomesonu kekere ati alaye ti yoo wa si awọn oṣiṣẹ irin-ajo ni ijinna, fun apẹẹrẹ, lilo ftp. Eyi yoo gba ọ laaye lati ṣe paṣipaarọ awọn atupale tuntun ni iyara, awọn atunto imudojuiwọn fun awọn eniyan tita, awọn ifarahan, ati bẹbẹ lọ.
  • Fun iraye si igba diẹ si awọn olumulo tabi awọn alabara lati ṣafihan sọfitiwia tabi media.

Wakọ idanwo VPS fun 30 rubles - ṣe fun ọ

30 rubles jẹ diẹ ti o ko paapaa fẹ lati mu kaadi jade lati sanwo ati idanwo. Nigba miiran a jẹ ọlẹ paapaa, ṣugbọn ni akoko yii a ṣe ohun gbogbo fun ọ. Ṣaaju ki o to ṣe ifilọlẹ awọn olupin sinu ogun, a ṣe idanwo kan lati ṣayẹwo gbogbo awọn alaye ati ṣafihan kini awọn olupin ni agbara ni idiyele idiyele yii. Lati jẹ ki o nifẹ diẹ sii, a ṣafikun iwọn pupọ ati ṣayẹwo bii iṣeto yii yoo ṣe ti iwuwo ati fifuye kọja awọn iye ti a ṣeto. 

Awọn ogun wà labẹ awọn fifuye ti awọn nọmba kan ti foju ero ti o ṣe orisirisi awọn iṣẹ-ṣiṣe lori ero isise ati ki o actively lo disk subsystem. Ibi-afẹde ni lati ṣe adaṣe ipo ipo iwuwo giga ati fifuye afiwera tabi tobi ju ija lọ.

Ni afikun si fifuye igbagbogbo, a fi sori ẹrọ awọn ẹrọ foju 3 ti o gba awọn metiriki sintetiki nipa lilo sysbench, awọn abajade apapọ ti eyiti a fun ni isalẹ, ati awọn ẹrọ foju 50 ti o ṣẹda fifuye afikun. Gbogbo awọn ẹrọ foju idanwo ni iṣeto kanna (1 mojuto, Ramu 512 GB, SSD 10 GB), aworan debian 9.6 boṣewa ti yan bi ẹrọ ṣiṣe, eyiti o funni si awọn olumulo lori RUVDS.

A ṣe afarawe ẹru naa ni iseda ati titobi ti o ṣe afiwe si ija:

  • Diẹ ninu awọn ẹrọ foju ṣe ifilọlẹ pẹlu ẹru kekere
  • Diẹ ninu awọn ẹrọ nṣiṣẹ iwe afọwọkọ idanwo ti n ṣedasilẹ fifuye lori ero isise (lilo ohun elo wahala)
  • Ni apakan ti o ku ti awọn ẹrọ foju, a ran iwe afọwọkọ kan ti o lo dd lati daakọ data lati data ti a ti pese tẹlẹ si disk pẹlu ṣeto opin nipa lilo pv (awọn apẹẹrẹ le ṣee rii nibi и nibi).

Paapaa, bi o ṣe ranti, a ni awọn ẹrọ mẹta ti o gba awọn metiriki sintetiki.

Lori ẹrọ kọọkan, iwe afọwọkọ kan ti ṣiṣẹ ni gigun kẹkẹ ni gbogbo iṣẹju 15, eyiti o nṣiṣẹ awọn idanwo sysbench boṣewa fun ero isise, iranti ati disk.

Iwe afọwọkọ sysbench.sh

#!/bin/bash
date +"%Y-%m-%d %H:%M:%S" >> /root/sysbench/results.txt
sysbench --test=cpu run >> /root/sysbench/results.txt
sysbench --test=memory run >> /root/sysbench/results.txt
sysbench --test=fileio --file-test-mode=seqwr run >> /root/sysbench/results.txt
sysbench --test=fileio --file-test-mode=seqrd run >> /root/sysbench/results.txt
sysbench --test=fileio --file-test-mode=rndrw run >> /root/sysbench/results.txt

Awọn abajade naa ni a gbekalẹ fun irọrun ni ọna kika sysbench, ṣugbọn awọn iye apapọ fun gbogbo akoko idanwo ni a mu lati gbogbo awọn ẹrọ, abajade le ṣee rii nibi:

Sysbanch-avg.txtsysbench 0.4.12: multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1

Doing CPU performance benchmark

Threads started!
Done.

Maximum prime number checked in CPU test: 10000

Test execution summary:
total time: 19.2244s
total number of events: 10000
total time taken by event execution: 19.2104
per-request statistics:
min: 1.43ms
avg: 1.92ms
max: 47.00ms
approx. 95 percentile: 3.02ms

Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 19.2104/0.00

sysbench 0.4.12: multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1

Doing memory operations speed test
Memory block size: 1K

Memory transfer size: 102400M

Memory operations type: write
Memory scope type: global
Threads started!
Done.

Operations performed: 104857600 (328001.79 ops/sec)

102400.00 MB transferred (320.32 MB/sec)

Test execution summary:
total time: 320.9155s
total number of events: 104857600
total time taken by event execution: 244.8399
per-request statistics:
min: 0.00ms
avg: 0.00ms
max: 139.41ms
approx. 95 percentile: 0.00ms

Threads fairness:
events (avg/stddev): 104857600.0000/0.00
execution time (avg/stddev): 244.8399/0.00

sysbench 0.4.12: multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1

Extra file open flags: 0
128 files, 16Mb each
2Gb total file size
Block size 16Kb
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing sequential write (creation) test
Threads started!
Done.

Operations performed: 0 Read, 131072 Write, 128 Other = 131200 Total
Read 0b Written 2Gb Total transferred 2Gb (320.1Mb/sec)
20251.32 Requests/sec executed

Test execution summary:
total time: 6.9972s
total number of events: 131072
total time taken by event execution: 5.2246
per-request statistics:
min: 0.01ms
avg: 0.04ms
max: 96.76ms
approx. 95 percentile: 0.03ms

Threads fairness:
events (avg/stddev): 131072.0000/0.00
execution time (avg/stddev): 5.2246/0.00

sysbench 0.4.12: multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1

Extra file open flags: 0
128 files, 16Mb each
2Gb total file size
Block size 16Kb
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing sequential read test
Threads started!
Done.

Operations performed: 131072 Read, 0 Write, 0 Other = 131072 Total
Read 2Gb Written 0b Total transferred 2Gb (91.32Mb/sec)
5844.8 Requests/sec executed

Test execution summary:
total time: 23.1054s
total number of events: 131072
total time taken by event execution: 22.9933
per-request statistics:
min: 0.00ms
avg: 0.18ms
max: 295.75ms
approx. 95 percentile: 0.77ms

Threads fairness:
events (avg/stddev): 131072.0000/0.00
execution time (avg/stddev): 22.9933/0.00

sysbench 0.4.12: multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 1

Extra file open flags: 0
128 files, 16Mb each
2Gb total file size
Block size 16Kb
Number of random requests for random IO: 10000
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Threads started!
Done.

Operations performed: 6000 Read, 4000 Write, 12800 Other = 22800 Total
Read 93.75Mb Written 62.5Mb Total transferred 156.25Mb (1341.5Kb/sec)
85.61 Requests/sec executed

Test execution summary:
total time: 152.9786s
total number of events: 10000
total time taken by event execution: 14.1879
per-request statistics:
min: 0.01ms
avg: 1.41ms
max: 210.22ms
approx. 95 percentile: 4.95ms

Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 14.1879/0.00

Awọn abajade jẹ itọkasi, ṣugbọn ko yẹ ki o gba bi QoS. 

Awọn ẹrọ ti o ṣẹda afikun fifuye

Sọfitiwia:

  • apt-gba imudojuiwọn
  • apt-gba igbesoke
  • apt-get install python-pip
  • pip fi sori ẹrọ mysql-connector-python-rf

Fi sori ẹrọ MariaDB, Bawo ni lati nibi:

apt-get install libmariadbclient-dev
mysql -e "INSTALL PLUGIN blackhole SONAME 'ha_blackhole.so';" -- нужно для test_employees_sha

Igbeyewo mimọ ya lati ibi:

Awọn database ti wa ni ransogun bi pato nibi:

mysql -t < employees.sql
mysql -t < test_employees_sha.sql

Ipilẹ idanwo kekere:

Table 

RowsCount 

Iwọn data (MB)

Iwọn atọka (KB)

apa apa 

9

0.02

16.00

dept_emp 

331143 

11.52

5648.00

dept_manager 

24 

0.02

16.00

abáni 

299379 

14.52

0.00

owo osu 

2838426 

95.63

0.00 

awọn akọle 

442783 

19.56

0.00

Iṣẹ idanwo akọkọ ti kọ lori orokun ni Python;

  1. getState: pada ipo
  2. gba Oṣiṣẹ: da awọn oṣiṣẹ pada (+ awọn owo osu, + awọn akọle) lati ibi ipamọ data
  3. patchEmployees: ayipada abáni oko
  4. insertSalary: ifibọ a ekunwo

Orisun iṣẹ (dbtest.py)

#!/usr/bin/python
import mysql.connector as mariadb
from flask import Flask, json, request, abort
from mysql.connector.constants import ClientFlag

app = Flask(__name__)

def getFields(cursor):
    results = {}
    column = 0
    for d in cursor.description:
        results[d[0]] = column
        column = column + 1
    return results

PAGE_SIZE = 30

@app.route("/")
def main():
    return "Hello!"

@app.route("/employees/<page>", methods=['GET'])
def getEmployees(page):
    offset = (int(page) - 1) * PAGE_SIZE
    connection = mariadb.connect(user='admin', password='q5XpRomdSr', database='employees')
    cursor = connection.cursor()
    cursor.execute("SELECT * FROM employees LIMIT {} OFFSET {}".format(PAGE_SIZE, offset))
    return {'employees': [i[0] for i in cursor.fetchall()]}

@app.route("/employee/<id>", methods=['GET'])
def getEmployee(id):
    id = int(id)
    connection = mariadb.connect(user='admin', password='q5XpRomdSr', database='employees')
    cursor = connection.cursor()
    cursor.execute("SELECT * FROM employees WHERE emp_no = {}".format(id))
    fields = getFields(cursor)
    employee = {}
    found = False
    for row in cursor.fetchall():
        found = True
        employee = {
            "birth_date": row[fields["birth_date"]],
            "first_name": row[fields["first_name"]],
            "last_name": row[fields["last_name"]],
            "gender": row[fields["gender"]],
            "hire_date": row[fields["hire_date"]]
        }
    if not found:
        abort(404)
    cursor.execute("SELECT * FROM salaries WHERE emp_no = {}".format(id))
    fields = getFields(cursor)
    salaries = []
    for row in cursor.fetchall():
        salary = {
            "salary": row[fields["salary"]],
            "from_date": row[fields["from_date"]],
            "to_date": row[fields["to_date"]]
        }
        salaries.append(salary)
    employee["salaries"] = salaries
    cursor.execute("SELECT * FROM titles WHERE emp_no = {}".format(id))
    fields = getFields(cursor)
    titles = []
    for row in cursor.fetchall():
        title = {
            "title": row[fields["title"]],
            "from_date": row[fields["from_date"]],
            "to_date": row[fields["to_date"]]
        }
        titles.append(title)
    employee["titles"] = titles
    return json.dumps({
        "status": "success",
        "employee": employee
    })

def isFieldValid(t, v):
    if t == "employee":
        return v in ["birdth_date", "first_name", "last_name", "hire_date"]
    else:
        return false

@app.route("/employee/<id>", methods=['PATCH'])
def setEmployee(id):
    id = int(id)
    content = request.json
    print(content)
    setList = ""
    data = []
    for k, v in content.iteritems():
        if not isFieldValid("employee", k):
            continue
        if setList != "":
            setList = setList + ", "
        setList = setList + k + "=%s"
        data.append(v)
    data.append(id)
    print(setList)
    print(data)
    connection = mariadb.connect(user='admin', password='q5XpRomdSr', database='employees', client_flags=[ClientFlag.FOUND_ROWS])
    cursor = connection.cursor()
    cursor.execute("UPDATE employees SET {} WHERE emp_no = %s".format(setList), data)
    connection.commit()
    if cursor.rowcount < 1:
        abort(404)
    return json.dumps({
        "status": "success"
    })

@app.route("/salary", methods=['PUT'])
def putSalary():
    content = request.json
    print(content)
    connection = mariadb.connect(user='admin', password='q5XpRomdSr', database='employees', client_flags=[ClientFlag.FOUND_ROWS])
    cursor = connection.cursor()
    data = [content["emp_no"], content["salary"], content["from_date"], content["to_date"]]
    cursor.execute("INSERT INTO salaries (emp_no, salary, from_date, to_date) VALUES (%s, %s, %s, %s)", data)
    connection.commit()
    return json.dumps({
        "status": "success"
    })


@app.route("/state", methods=['GET'])
def getState():
    return json.dumps({
        "status": "success",
        "state": "working"
    })

if __name__ == '__main__':
    app.run(host='0.0.0.0',port='5002')

Išọra Labẹ ọran kankan o yẹ ki o gba iṣẹ yii bi apẹẹrẹ tabi itọsọna!

Awọn idanwo ni a ṣe pẹlu lilo JMeter atijọ ti o dara. Awọn idanwo lẹsẹsẹ ti o to lati iṣẹju 15 si awọn wakati 2 ni a ṣe ifilọlẹ, laisi awọn idilọwọ, ipin ogorun awọn ibeere yatọ, ati iṣelọpọ yatọ lati awọn ibeere 300 si 600 fun iṣẹju kan. Nọmba awọn okun lati 50 si 500.

Nitori otitọ pe data data kere pupọ, aṣẹ naa:

mysql -e "SHOW ENGINE INNODB STATUS"

Ṣe afihan pe:

Buffer pool hit rate 923 / 1000, young-making rate 29 / 1000 not 32 / 1000

Ni isalẹ ni awọn akoko idahun apapọ fun awọn ibeere:

Aami

Apapọ

Media

90% ila

95% ila

99% ila

min

Max

gba Oṣiṣẹ

37.64

12.57

62.28

128.5

497.57

5

4151.78

getState

17

7.57

30.14

58.71

193

3

2814.71

patch Oṣiṣẹ

161.42

83.29

308

492.57

1845.14

5

6639.4

fi ekunwo

167.21

86.93

315.34

501.07

1927.12

7

6722.44

O le ṣoro fun ọ lati ṣe idajọ lati awọn abajade sintetiki wọnyi bawo ni VPS yii ṣe dara fun awọn iṣẹ ṣiṣe pato rẹ ati, ni gbogbogbo, awọn ọna ti a ṣe akojọ ni opin si awọn ọran wọnyẹn ti a ni lati ṣe pẹlu ni fọọmu kan tabi omiiran kedere ko tán. A pe ọ lati fa awọn ipinnu tirẹ ati idanwo olupin fun 30 rubles lori awọn ohun elo gidi ati awọn iṣẹ ṣiṣe ati daba awọn aṣayan rẹ fun iṣeto ni awọn asọye.

orisun: www.habr.com

Fi ọrọìwòye kun