脑+ 30卢布的VPS =?

当所有必要的小东西都在手边时,这是很好的选择:一支书写良好的笔和笔记本,一支削尖的铅笔,一支舒适的鼠标,几根额外的电线等。 这些不起眼的事物并没有引起人们的注意,而是增加了舒适的生活。 各种移动和桌面应用程序的情况与此相同:用于较长的屏幕截图,减小图像大小,计算个人理财,字典,翻译器,转换器等。 您是否有这样的VPS-价格便宜,随时可用并带来许多好处? 不,不是您公司所拥有的,而是您自己的“口袋”。 我们认为,在2019年没有小型VPS的情况下,某种程度上很难过,就像在演讲中没有通常的钢笔一样。 为什么要伤心? 夏天是。 好吧,像夏天。 IT夏季:坐在家里,削减任何喜爱的项目,不要后悔。 总的来说,思想和完成。


同志们,共产主义来了

他是他自己的-我们三十年来的VPS


我们阅读了3-4年前竞争对手和用户撰写的文章,其中介绍了为什么不需要廉价的VPS。 是的,那么,VPS“只花一分钱”是纯粹的营销手段,不能提供正常的工作机会。 但是时代在变,虚拟资源的成本越来越低,我们准备为每月提供30卢布的服务:

  • 处理器:Intel Xeon 2 GHz(1核)
  • Linux系统(可供选择的Debian,Ubuntu,CentOS)
  • 1个专用IPv4地址
  • 10 GB用于在企业级快速SSD上存储数据
  • 内存:512 MB
  • 每秒计费
  • 无限流量

关税受其他技术限制,详情在我们的超酷优惠页面上 -VPS为30卢布。

谁应该使用这样的虚拟服务器? 是的,几乎每个人:初学者,爱好者,经验丰富的开发人员,DIY爱好者,甚至是一些公司。

此VPS适用于什么?


我们认为哈伯的读者肯定会找到他们自己的应用这种方式的方法,但是他们决定将自己的想法组合在一起-否则突然有人需要它,但是这些人不知道吗?

  • 发布您的简单站点,投资组合,带有代码的简历等。 当然,它自己设计的网站给雇主留下了积极的印象。 将其放在您的VPS上,并由您自己负责网站的安全性和稳定性,而不由共享托管人员负责。
  • 将VPS用于教育目的:发布项目,研究服务器和服务器操作系统的功能,尝试DNS,挖掘小型培训站点。
  • 用于电话。 有时,个人企业家,自由职业者或非常小的公司迫切需要IP电话,并且该电话的运营商非常贪婪。 很简单:我们拿起服务器,从IP电话运营商那里购买号码,设置虚拟PBX并创建内部号码(如果需要)。 节省的巨款。
  • 使用服务器来测试您的应用程序。
  • 使用服务器进行DIY实验,包括管理和收集来自智能家居系统传感器的数据。
  • 一种不常见的应用方法是在服务器上放置交易所交易的虚拟助手,即交易机器人。 您将对服务器的稳定性和安全性负全部责任,这意味着您将获得用于股票市场交易的受控工具。 好吧,突然之间有人喜欢或计划:-)

公司领域中有这样的VPS应用程序。 除了已经提到的电话服务外,您还可以实现一些有趣的功能。 例如:

  • 放置小型数据库和信息,以供远距离旅行的员工使用,例如使用ftp。 这将使您能够快速交换新的分析,销售人员的更新配置,演示文稿等。
  • 向用户或客户端授予临时访问权以演示软件或多媒体。

VPS试驾30卢布-为您服务


30卢布是如此之小,以至于甚至都不愿获得卡付款和测试。 我们有时也很懒,但是这次我们为您做了所有事情。 在启动服务器战斗之前,我们进行了测试以检查所有详细信息,并显示在此价格下服务器可以提供的功能。 为了使它更有趣,我们添加了极限运动,并检查了密度和负荷超过我们设置的值时此配置的行为。

主机承受着许多虚拟机的负载,这些虚拟机在处理器上执行各种任务并积极使用磁盘子系统。 目标是模拟高放置密度和可比或大于战斗负荷的负荷。

除了恒定的负载,我们还安装了3个使用sysbench收集综合指标的虚拟机,其平均结果如下所示,还有50个虚拟机创建了额外的负载。 所有测试虚拟机都具有相同的配置(1核,512 GB RAM,10 GB SSD),因此选择了标准debian 9.6映像作为操作系统,该映像在RUVDS上提供给用户。

负载在性质和大小上与战斗可比拟:

  • 一些虚拟机是在低负载下启动的。
  • 一些机器“扭曲”了一个测试场景,该场景模拟了处理器上的负载(使用Stress实用程序)
  • 在其余的虚拟机上,我们运行了一个脚本,该脚本使用dd来将数据从预先准备好的数据复制到具有pv限制的磁盘上(示例可在此处此处找到)。

另外,您还记得,我们有三辆汽车在收集综合指标。

每15分钟在每台计算机上循环运行一次脚本,该脚本针对处理器,内存和磁盘运行标准sysbench测试。

脚本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


sysbench', , :

Sysbanch-avg.txt
sysbench 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

, QoS. 



:

  • apt-get update
  • apt-get upgrade
  • apt-get install python-pip
  • pip install mysql-connector-python-rf

MariaDB, :

apt-get install libmariadbclient-dev
mysql -e "INSTALL PLUGIN blackhole SONAME 'ha_blackhole.so';" --   test_employees_sha

:

:

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

:
Table 
RowsCount 
Data size (MB)
Index size (KB)
departments 
9
0.02
16.00
dept_emp 
331143 
11.52
5648.00
dept_manager 
24 
0.02
16.00
employees 
299379 
14.52
0.00
salaries 
2838426 
95.63
0.00 
titles 
442783 
19.56
0.00

, :

  1. getState:
  2. getEmployee: employee (+salaries, +titles)
  3. patchEmployee: employee
  4. insertSalary: salary

(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')

! !

JMeter. 15 2 , , , 300 600 . 50 500.

, , :

mysql -e "SHOW ENGINE INNODB STATUS"

:

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

:
Label
Average
Median
90% Line
95% Line
99% Line
Min
Max
getEmployee
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
patchEmployee
161.42
83.29
308
492.57
1845.14
5
6639.4
putSalary
167.21
86.93
315.34
501.07
1927.12
7
6722.44

, VPS , , . . 30 .

Source: https://habr.com/ru/post/zh-CN464571/


All Articles