为什么要从VPS转向Dedicated Server

用linode好几年了,但是有时候发现硬盘的I/O非常不稳定,如下面的这个VPS的benchmark所示,第一次测速只有 9.4 MB/s,这么差的性能已经非常影响线上业务了。究其原因,大概是因为你有一个比较折腾的邻居,因为这些VPS都是用虚拟化技术在同一台Dedicated Server上切出来的,你永远不会知道你的邻居在干什么,所以VPS的硬盘性能注定不会稳定,即使现在的VPS跑分很好看,可能明天就不行了。

[root@ ~]# wget -qO- bench.sh | bash
----------------------------------------------------------------------
CPU model : AMD EPYC 7501 32-Core Processor
Number of cores : 2
CPU frequency : 2000.002 MHz
Total size of Disk : 79.0 GB (12.0 GB Used)
Total amount of Mem : 3789 MB (791 MB Used)
Total amount of Swap : 511 MB (17 MB Used)
System uptime : 61 days, 15 hour 3 min
Load average : 0.16, 0.18, 0.15
OS : CentOS 7.7.1908
Arch : x86_64 (64 Bit)
Kernel : 3.10.0-957.el7.x86_64
----------------------------------------------------------------------
I/O speed(1st run) : 9.4 MB/s
I/O speed(2nd run) : 47.0 MB/s
I/O speed(3rd run) : 377 MB/s
Average I/O speed : 144.5 MB/s
----------------------------------------------------------------------
Node Name IPv4 address Download Speed
CacheFly 205.234.175.175 109MB/s
Linode, Tokyo2, JP 139.162.65.37 14.4MB/s
Linode, Singapore, SG 139.162.23.4 10.3MB/s
Linode, London, UK 176.58.107.39 33.3MB/s
Linode, Frankfurt, DE 139.162.130.8 28.9MB/s
Linode, Fremont, CA 50.116.14.9 34.0MB/s
Softlayer, Dallas, TX 173.192.68.18 42.8MB/s
Softlayer, Seattle, WA 67.228.112.250 30.7MB/s
Softlayer, Frankfurt, DE 159.122.69.4 12.1MB/s
Softlayer, Singapore, SG 119.81.28.170 7.88MB/s
Softlayer, HongKong, CN 119.81.130.170 8.74MB/s
----------------------------------------------------------------------

而且普通的linode套餐CPU可能也是共享的,如下图所示,linode推出了Dedicated CPU instances的套餐,按照我的理解,这个套餐的意思应该是CPU独享,但是SSD仍然是共享的,可以看出来,这个价格已经很不划算了,不如自己买独立服务器切小鸡。

hivelocity TPA2 datacenter dedicated server benchmark

[root@ ~]# wget -qO- bench.sh | bash
----------------------------------------------------------------------
CPU model : Intel(R) Xeon(R) CPU E3-1230 v5 @ 3.40GHz
Number of cores : 8
CPU frequency : 1820.983 MHz
Total size of Disk : 432.8 GB (1.2 GB Used)
Total amount of Mem : 15709 MB (174 MB Used)
Total amount of Swap : 7935 MB (0 MB Used)
System uptime : 0 days, 0 hour 14 min
Load average : 0.00, 0.01, 0.02
OS : CentOS 7.6.1810
Arch : x86_64 (64 Bit)
Kernel : 3.10.0-957.el7.x86_64
----------------------------------------------------------------------
I/O speed(1st run) : 349 MB/s
I/O speed(2nd run) : 344 MB/s
I/O speed(3rd run) : 344 MB/s
Average I/O speed : 345.7 MB/s
----------------------------------------------------------------------
Node Name IPv4 address Download Speed
CacheFly 205.234.175.175 110MB/s
Linode, Tokyo2, JP 139.162.65.37 12.5MB/s
Linode, Singapore, SG 139.162.23.4 9.92MB/s
Linode, London, UK 176.58.107.39 22.4MB/s
Linode, Frankfurt, DE 139.162.130.8 19.8MB/s
Linode, Fremont, CA 50.116.14.9 31.3MB/s
Softlayer, Dallas, TX 173.192.68.18 37.7MB/s
Softlayer, Seattle, WA 67.228.112.250 17.4MB/s
Softlayer, Frankfurt, DE 159.122.69.4 11.5MB/s
Softlayer, Singapore, SG 119.81.28.170 5.39MB/s
Softlayer, HongKong, CN 119.81.130.170 6.45MB/s
----------------------------------------------------------------------

[root@]# smartctl --all /dev/sda
smartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-957.el7.x86_64] (local build)
Copyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family: Crucial/Micron BX/MX1/2/3/500, M5/600, 1100 SSDs
Device Model: MICRON_M510DC_MTFDDAK480MBP
Serial Number: 160511B4E42F
LU WWN Device Id: 5 00a075 111b4e42f
Firmware Version: 0013
User Capacity: 480,103,981,056 bytes [480 GB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
Device is: In smartctl database [for details use: -P show]
ATA Version is: ACS-2, ATA8-ACS T13/1699-D revision 6
SATA Version is: SATA 3.1, 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Sat Apr 4 04:51:23 2020 EDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status: (0x80) Offline data collection activity
was never started.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 2235) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 6) minutes.
Conveyance self-test routine
recommended polling time: ( 3) minutes.
SCT capabilities: (0x0035) SCT Status supported.
SCT Feature Control supported.
SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x002f 100 100 050 Pre-fail Always - 0
5 Reallocate_NAND_Blk_Cnt 0x0032 100 100 001 Old_age Always - 0
9 Power_On_Hours 0x0032 100 100 001 Old_age Always - 26000
12 Power_Cycle_Count 0x0032 100 100 001 Old_age Always - 37
170 Reserved_Block_Count 0x0033 100 100 010 Pre-fail Always - 0
171 Program_Fail_Count 0x0032 100 100 001 Old_age Always - 0
172 Erase_Fail_Count 0x0032 100 100 001 Old_age Always - 0
173 Ave_Block-Erase_Count 0x0033 100 100 000 Pre-fail Always - 31
174 Unexpect_Power_Loss_Ct 0x0032 100 100 001 Old_age Always - 26
184 Error_Correction_Count 0x0033 100 100 050 Pre-fail Always - 0
187 Reported_Uncorrect 0x0032 100 100 001 Old_age Always - 0
188 Command_Timeout 0x0032 100 100 001 Old_age Always - 0
194 Temperature_Celsius 0x0022 072 060 000 Old_age Always - 28 (Min/Max 19/40)
195 Cumulativ_Corrected_ECC 0x003a 100 100 001 Old_age Always - 1498566
197 Current_Pending_Sector 0x0032 100 100 001 Old_age Always - 0
198 Offline_Uncorrectable 0x0030 100 100 001 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0032 100 100 001 Old_age Always - 0
202 Percent_Lifetime_Remain 0x0018 100 100 001 Old_age Offline - 0
206 Write_Error_Rate 0x000e 100 100 001 Old_age Always - 0
247 Host_Program_Page_Count 0x0032 100 100 000 Old_age Always - 765505467
248 FTL_Program_Page_Count 0x0032 100 100 000 Old_age Always - 484034379

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
Num Test_Description Status Remaining LifeTime(hours) LBA_of_first_error
# 1 Vendor (0xff) Completed without error 00% 7157 -
# 2 Vendor (0xff) Completed without error 00% 25 -

SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

可以看出来TPA2机房网络还可以的,SSD速度感觉很一般了,整体配置还行。硬盘的型号是MICRON_M510DC_MTFDDAK480MBP,是美光2015年的老盘了,通电时间26000小时😔,运气真是不咋地

ovh.ie vps benchmark

root@:~# wget -qO- bench.sh | bash
----------------------------------------------------------------------
CPU model : Intel Core Processor (Haswell, no TSX)
Number of cores : 1
CPU frequency : 2399.988 MHz
Total size of Disk : 20.1 GB (1.2 GB Used)
Total amount of Mem : 1945 MB (77 MB Used)
Total amount of Swap : 0 MB (0 MB Used)
System uptime : 0 days, 3 hour 17 min
Load average : 0.00, 0.00, 0.00
OS : Ubuntu 18.04.4 LTS
Arch : x86_64 (64 Bit)
Kernel : 4.15.0-72-generic
----------------------------------------------------------------------
I/O speed(1st run) : 185 MB/s
I/O speed(2nd run) : 211 MB/s
I/O speed(3rd run) : 206 MB/s
Average I/O speed : 200.7 MB/s
----------------------------------------------------------------------
Node Name IPv4 address Download Speed
CacheFly 205.234.175.175 11.5MB/s
Linode, Tokyo2, JP 139.162.65.37 4.92MB/s
Linode, Singapore, SG 139.162.23.4 5.81MB/s
Linode, London, UK 176.58.107.39 11.6MB/s
Linode, Frankfurt, DE 139.162.130.8 11.7MB/s
Linode, Fremont, CA 50.116.14.9 9.54MB/s
Softlayer, Dallas, TX 173.192.68.18 8.78MB/s
Softlayer, Seattle, WA 67.228.112.250 6.28MB/s
Softlayer, Frankfurt, DE 159.122.69.4 11.0MB/s
Softlayer, Singapore, SG 119.81.28.170 4.85MB/s
Softlayer, HongKong, CN 119.81.130.170 4.54MB/s
----------------------------------------------------------------------

这是ovh.ie的一台最低配的SSD VPS,好像是3欧元一个月。可以看得出来各方面都很一般了。买这个小鸡主要是弄个ovh账户,以后买独服方便。

DP线质量与闪屏

今天显示器突然狂闪,换了一台主机还是闪,google了一下看到可能与视频线的质量有关,把戴尔原装的mini dp线换成了一个15元的DP线就不闪了。

打算再买个好的线,CYK好像不错,不过要100元一根。现在的厂商为了节省成本,用这么差的线也是够了。。。

服务器driver类型 对网站 I/O的影响

在hostloc看到了这一段讨论,感觉很不错,记录下来

I/O响应快慢和硬盘读写速度关系不大,就类似于延迟和带宽的差距。
I/O响应快慢取决于硬盘类型,同等RAID情况下,SSD普遍好于HDD。
主要HDD机械硬盘磁头定位一类物理耗时要长,I/O响应快会加快网站速度。
至于硬盘读写速度,主要影响的是网站负载能力。
比如1个用户以5MB/s的速度下载一张图片,那他占用的硬盘独写就是5MB/s。
如果10个用户以相同速度下载一张图片,那他们就会占用50MB/s。
如果读写峰值是100MB/s,100个人下载,那带宽再大他们每人下载速度也只有1MB/s。
主机商限制I/O主要是为了公平分配硬盘占用。
比如SSD最大读写速度是2000MB/s,限制到100MB/s就能保证至少20个用户同时使用。
一般个人网站并发读写根本不会超过50MB/s。

正解,需要指出的是,SSD的IO可以叠加计算,而HDD的话,峰值100MB/S,10个人同时干,是达不到10M/S的,有5M/S就不错了,100个人干的话就是几十KB的级别了。HDD对多线程支持非常差劲,HDD在RAID情况下略好,不过仍旧完败于SSD。

ESXi 独服切小鸡成功了

写上一篇博客时,我的独服用ESXi切小鸡网络总是连不上,后来改用PVE就很顺利连上了,后来思考了一下,感觉ESXi可能也不用设置什么网络的,直接桥接母鸡的网卡就OK了,今天测试了一下果然成功了。安装完ESXi以后不用设置任何网络设置,直接创建虚拟机,使用默认的VM network即可,如果安装的是windows,虚拟机创建完以后在控制面板里面设置一下静态ip就可以联网了,如果是ubuntu等Linux,需要在安装系统的时候设置静态ip。

顺便贴一下dedicated.com切出来的小鸡的benchmark

----------------------------------------------------------------------
CPU model : Intel(R) Xeon(R) CPU E3-1271 v3 @ 3.60GHz
Number of cores : 2
CPU frequency : 3599.997 MHz
Total size of Disk : 49.1 GB (7.0 GB Used)
Total amount of Mem : 3945 MB (1815 MB Used)
Total amount of Swap : 3944 MB (0 MB Used)
System uptime : 0 days, 0 hour 10 min
Load average : 1.63, 0.89, 0.38
OS : Ubuntu 18.04.4 LTS
Arch : x86_64 (64 Bit)
Kernel : 4.15.0-91-generic
----------------------------------------------------------------------
I/O speed(1st run) : 233 MB/s
I/O speed(2nd run) : 249 MB/s
I/O speed(3rd run) : 245 MB/s
Average I/O speed : 242.3 MB/s
----------------------------------------------------------------------
Node Name IPv4 address Download Speed
CacheFly 205.234.175.175 93.0MB/s
Linode, Tokyo2, JP 139.162.65.37 12.7MB/s
Linode, Singapore, SG 139.162.23.4 5.70MB/s
Linode, London, UK 176.58.107.39 9.61MB/s
Linode, Frankfurt, DE 139.162.130.8 8.26MB/s
Linode, Fremont, CA 50.116.14.9 78.0MB/s
Softlayer, Dallas, TX 173.192.68.18 67.4MB/s
Softlayer, Seattle, WA 67.228.112.250 77.4MB/s
Softlayer, Frankfurt, DE 159.122.69.4 5.27MB/s
Softlayer, Singapore, SG 119.81.28.170 13.0MB/s
Softlayer, HongKong, CN 119.81.130.170 15.4MB/s
----------------------------------------------------------------------

这款独服用的SSD是三星850PRO,可以看的出来,开出来的小鸡的SSD I/O比母鸡差了一点

ESXi 从入门到放弃

最近几天折腾ESXi一直失败搞得我很沮丧,ESXi的网络配置对于我而言太复杂了,而且ESXi有不少坑,比如ssh被攻击次数太多的话就无法登录了,必须要设置防火墙

今天晚上试用了一下Proxmox VE,一切都变得美好起来,太简单太顺利了,成功的开好了windows小鸡和ubuntu小鸡,而且网络配置没有任何问题,小鸡直接桥接母鸡然后设置一下static ip就OK,太愉快了

说回来我的计算机网络知识差不多都忘记了,趁着这次机会再补习一下

QuadraNet dedicated server(LA) benchmark

root@:~# wget -qO- bench.sh | bash
----------------------------------------------------------------------
CPU model : Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz
Number of cores : 8
CPU frequency : 1300.456 MHz
Total size of Disk : 914.0 GB (1.9 GB Used)
Total amount of Mem : 15999 MB (123 MB Used)
Total amount of Swap : 2047 MB (0 MB Used)
System uptime : 0 days, 0 hour 3 min
Load average : 0.05, 0.13, 0.06
OS : Ubuntu 18.04.3 LTS
Arch : x86_64 (64 Bit)
Kernel : 4.15.0-91-generic
----------------------------------------------------------------------
I/O speed(1st run) : 432 MB/s
I/O speed(2nd run) : 431 MB/s
I/O speed(3rd run) : 429 MB/s
Average I/O speed : 430.7 MB/s
----------------------------------------------------------------------
Node Name IPv4 address Download Speed
CacheFly 205.234.175.175 88.4MB/s
Linode, Tokyo2, JP 139.162.65.37 6.75MB/s
Linode, Singapore, SG 139.162.23.4 3.67MB/s
Linode, London, UK 176.58.107.39 5.12MB/s
Linode, Frankfurt, DE 139.162.130.8 6.14MB/s
Linode, Fremont, CA 50.116.14.9 52.3MB/s
Softlayer, Dallas, TX 173.192.68.18 41.0MB/s
Softlayer, Seattle, WA 67.228.112.250 47.7MB/s
Softlayer, Frankfurt, DE 159.122.69.4 6.49MB/s
Softlayer, Singapore, SG 119.81.28.170 8.65MB/s
Softlayer, HongKong, CN 119.81.130.170 10.5MB/s
----------------------------------------------------------------------

root@:~# smartctl --all /dev/sda
smartctl 6.6 2016-05-31 r4324 [x86_64-linux-4.15.0-91-generic] (local build)
Copyright (C) 2002-16, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model: CT1000MX500SSD1
Serial Number: 2007E28BE01A
LU WWN Device Id: 5 00a075 1e28be01a
Firmware Version: M3CR032
User Capacity: 1,000,204,886,016 bytes [1.00 TB]
Sector Sizes: 512 bytes logical, 4096 bytes physical
Rotation Rate: Solid State Device
Form Factor: 2.5 inches
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: ACS-3 T13/2161-D revision 5
SATA Version is: SATA >3.2 (0x1ff), 6.0 Gb/s (current: 6.0 Gb/s)
Local Time is: Sat Mar 28 03:41:20 2020 PDT
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status: (0x80) Offline data collection activity
was never started.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 0) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 2) minutes.
Extended self-test routine
recommended polling time: ( 30) minutes.
Conveyance self-test routine
recommended polling time: ( 2) minutes.
SCT capabilities: (0x0031) SCT Status supported.
SCT Feature Control supported.
SCT Data Table supported.

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x002f 100 100 000 Pre-fail Always - 0
5 Reallocated_Sector_Ct 0x0032 100 100 010 Old_age Always - 0
9 Power_On_Hours 0x0032 100 100 000 Old_age Always - 27
12 Power_Cycle_Count 0x0032 100 100 000 Old_age Always - 9
171 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 0
172 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 0
173 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 0
174 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 5
180 Unused_Rsvd_Blk_Cnt_Tot 0x0033 000 000 000 Pre-fail Always - 27
183 Runtime_Bad_Block 0x0032 100 100 000 Old_age Always - 0
184 End-to-End_Error 0x0032 100 100 000 Old_age Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
194 Temperature_Celsius 0x0022 076 070 000 Old_age Always - 24 (Min/Max 0/30)
196 Reallocated_Event_Count 0x0032 100 100 000 Old_age Always - 0
197 Current_Pending_Sector 0x0032 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0030 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x0032 100 100 000 Old_age Always - 0
202 Unknown_SSD_Attribute 0x0030 100 100 001 Old_age Offline - 0
206 Unknown_SSD_Attribute 0x000e 100 100 000 Old_age Always - 0
210 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 0
246 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 143958177
247 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 1215882
248 Unknown_Attribute 0x0032 100 100 000 Old_age Always - 301139

SMART Error Log Version: 1
No Errors Logged

SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]

SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Completed [00% left] (0-65535)
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

这是一款QN 洛杉矶机房的独服,价格是$79/month。处理器和内存都中规中矩,但是SSD似乎给了一块全新的美光MX500,还是非常不错的。

affiliate需要熟练掌握的技术

1. html css javascript, 这三个就不说了
2. php mysql, affiliate大多数用的软件基本上都是 php mysql架构的,因此需要熟练掌握php mysql知识,以及一个LNMP脚本(大佬推荐军哥的LNMP脚本)
3. linux基本的运维知识,学习shell脚本,掌握docker技术,这个是新的趋势,还有计算机网络,熟练操作VPS, cloud,dedicated server
4. python mongodb, 这两个用来采集整理存储数据都非常方便

大概就是以上这些了,想到了再补充,把上面这些学到极致也是很不容易了