Home Database Mysql Tutorial 互联网创业的准备数据库:硬盘iops、mysql

互联网创业的准备数据库:硬盘iops、mysql

Jun 07, 2016 pm 05:56 PM
mysql internet Prepare Start a business database harddisk

《互联网创业的准备》系列文章 硬盘常识: 机械硬盘HDD固态硬盘SSD 最小单位1个扇区为512B,或4K(2012年民用普及)1个分页为4K、8K或更高() 性能因素转速(rpm):5400、7200、1w、1.5w层数:SLC(单层快)、MLC(双层慢)、TLC(三层更慢,SSD暂未采用,

《互联网创业的准备》系列文章——

硬盘常识:

  机械硬盘HDD 固态硬盘SSD

最小单位 1个扇区为512B,或4K(2012年民用普及) 1个分页为4K、8K或更高()

性能因素 转速(rpm):5400、7200、1w、1.5w 层数:SLC(单层快)、MLC(双层慢)、TLC(三层更慢,SSD暂未采用,U盘大量采用)

接口 SATA 3G、SATA 6G(2012年民用普及)、SAS 6G SATA 3G、SATA 6G、SAS 6G、PCI-E

尺寸 2.5英寸、3.5英寸 2.5英寸、PCI-E版型

常见品牌 西部数据、希捷 Intel、镁光(Crucial)、浦科特(PLEXTOR)

硬盘性能指标:

连续读写(常用单位为MB/s):文件在硬盘上存储位置是连续的,适用场景:大文件拷贝(比如视频音乐)。速度即使很高,对数据库性能也没有参考价值。

4K随机读写(常用单位为iops):在硬盘上随机位置读写数据,每次4KB,适用场景:操作系统运行、软件运行、数据库。(图片静态服务器、视频静态服务器是大文件,测试64K随机或更大)

 

常用硬盘性能测试软件:

Windows:AS SSD Benchmark、CrystalDiskMark、HD Tune Pro、iometer

Linux:iometer

Align I/Os:硬盘IO大小。测试设备时根据硬盘最小单位进行选择,机械硬盘上选512B或4K,SSD上选4K、8K等。测试分区时受分区sector size影响。由于Linux ext3的sector size为4096,所以在扇区为512B的机械硬盘上也无法选择Align I/Os on 512B进行测试,测试效果不佳。vps无法进行设备测试,如果是自购服务器,应使用设备测试。

Seq 即 Sequential 即连续读写。AS SSD会先以16MB的尺寸为单位,持续向受测分区写入生成1个达到1GB大小的文件,然后再以同样的单位尺寸读取这个,最后计算平均成绩而给出结果。

4K 即 Random 4k, Queue Depth=1 即 随机4K并发1个队列。AS SSD会以512KB的单位尺寸生成1GB大小的测试文件,然后在其地址范围(LBA)内进行随机4KB单位尺寸进行写入及读取测试,直到跑遍这个范围为止,最后同样计算平均成绩给出结果。

4K QD32 即 Random 4k, Queue Depth=32 即 随机4K并发32个队列。

4K-64Thrd 即 4K, 64 Thread 即 随机4K并发64个线程,和 4K QD64是一个意思。AS SSD会生成64个16MB大小的测试文件(共计1GB),然后同时以4KB的单位尺寸,同时在这64个文件中进行写入和读取测试,最后依然以平均成绩为结果。

通过AS SSD可以看出,iops与MB/s可以直接换算,比如4K读取是6227iops,即每秒钟可以读取6227个4K的文件,即 6227 * 4K / 1024 = 24.3 MB/s。

Intel的SSD性能数据采用iometer 4K QD32的测试结果:

价格与速度:

  型号 容量 2012价格 4K QD32随机读/写(iops) 4K QD64 连续读写(MB/s)

民用 机械7200rpm 3.5英寸 SATA 6G 希捷Barracuda 7200.14 3TB ¥1.1k 409/365 386/291 200/180

企业级 机械10000rpm 2.5英寸 SAS 6G  希捷Savvio 10K.5 300GB ¥1k 750/700   170/170

企业级 机械15000rpm 2.5英寸 SAS 6G 希捷Savvio 15K.3 300GB ¥2.2k      

企业级 固态SLC 2.5英寸 SATA 3G Intel X25-E 32G ¥2.5k 3.5w/3.3k   250/170

企业级 固态MLC PCI-E Intel 910 400G ¥14w 9w/3.8w   1000/750

企业级 固态MLC PCI-E Intel 710 100G ¥2.5k 3.8w/2.3k   270/170

民用 固态MLC 2.5英寸 SATA 6G Intel 520 120G ¥840 2.5w/8w   550/500

民用 固态MLC 2.5英寸 SATA 6G 镁光 M4 128G ¥800 7.8w/4.2w 7w/4w 500/175

 

为什么民用SSD的iops很高价格却很低,而企业级SSD的iops有的很低而价格却很高?因为企业级SSD的耐用性高,比如Intel 710 100G寿命为4K写入500TB,即5000次全盘写入。

Intel SSD寿命指标:smart中的“E8:Avai lable Reserved Space”:可用的预留闪存数量、“E9:Media Wearout Indicator”:闪存磨耗指数。其他厂商的SSD类似,比如镁光的wear leaving count。

SSD新盘的剩余磨损为100,当低于10时,应更换,报废。

 

todo:数据库的选择

关系型数据库用Mysql还是PostgreSQL,或者全用NoSQL?mongo还是hbase?

Mysql 和 PostgreSQL都可以。mysql用的人多,但是oracle收购sun以后,把mysql限制的更加封闭,正在衰落,和可能和OpenOffice一样被oracle整死,免备案空间,衍生出LibreOffice。但不用很担心,即使mysql被oracle整死,也会衍生出开源版本,使用方式一样。

关系型数据库和NoSQL搭配使用较好,关系型适合底层业务,NoSQL适合上层业务。关注淘宝hbase的使用。

Mysql性能与硬盘iops的关系:

mysql可以把读取结果放在内存中,即query cache,所以db server安装大内存即可实现只读内存、不读硬盘。

当预计数据量会增长到超过内存大小时,进行分表(把一个表中的数据拆分),放到多个大内存服务器上,保证每个服务器上的数据都小于内存大小,香港服务器,即可实现全部缓存。

2012年内存价格:UDIMM no ECC DDR3 1600民用内存 ¥270/8GB,RDIMM ECC DDR3 1600服务器内存 ¥440/8G。但一台服务器能安装的内存有限,2012年典型的Dell服务器有24个插槽,主板芯片支持768G内存,2012年DDR3内存生产工艺最高是单条8G(DDR4已实现单条16G,但主板尚未支持DDR4),所以一台服务器最大内存192G(¥440 * 24条 = 1w)。

数据库写入时必须写硬盘(否则就不叫持久化存储了……),¥2.5k的Intel 710企业级SSD的写入iops为2.3k,而万转硬盘的iops为700,如果要达到SSD的性能,需要多块万转硬盘组RAID。如果使用iops为3w的SSD,性能比机械硬盘提升了30倍。

如果数据量不大,远低于192G,就不需要做分表了吗?

仍然要分表,原因有2个:

1、大内存会提升mysql读取性能,但并发读取能力也是有上限的,香港虚拟主机,这时受CPU性能限制,2012年典型的服务器是双路,即2个8核CPU(mysql内存并发待测试)。

2、内存很大,对并发写入能力没有作用,写入能力完全依赖于硬盘的iops。一台服务器的写入性能很有限,请看下面的测试。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

How to open phpmyadmin How to open phpmyadmin Apr 10, 2025 pm 10:51 PM

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

How to use single threaded redis How to use single threaded redis Apr 10, 2025 pm 07:12 PM

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.

MySQL and SQL: Essential Skills for Developers MySQL and SQL: Essential Skills for Developers Apr 10, 2025 am 09:30 AM

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

MySQL's Place: Databases and Programming MySQL's Place: Databases and Programming Apr 13, 2025 am 12:18 AM

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

Monitor Redis Droplet with Redis Exporter Service Monitor Redis Droplet with Redis Exporter Service Apr 10, 2025 pm 01:36 PM

Effective monitoring of Redis databases is critical to maintaining optimal performance, identifying potential bottlenecks, and ensuring overall system reliability. Redis Exporter Service is a powerful utility designed to monitor Redis databases using Prometheus. This tutorial will guide you through the complete setup and configuration of Redis Exporter Service, ensuring you seamlessly build monitoring solutions. By studying this tutorial, you will achieve fully operational monitoring settings

See all articles