You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1007 lines
31 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html lang="en-us">
<head><meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "BlogPosting",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https:\/\/h.cowbay.org"
},
"articleSection" : "post",
"name" : "[筆記] 測試 USB 3.1 Gen2 NVME SSD 外接盒 \x26 內建pci-e ssd \x26 外接SATA SSD \/ Bencmark With External Internal Nvme Ssd and External Sata Ssd",
"headline" : "[筆記] 測試 USB 3.1 Gen2 NVME SSD 外接盒 \x26 內建pci-e ssd \x26 外接SATA SSD \/ Bencmark With External Internal Nvme Ssd and External Sata Ssd",
"description" : "\x3cp\x3e前幾天在淘寶上買了個 SSK 的USB 3.1 Gen2 (type-c) NVME SSD 外接盒\n手邊也剛好有一條多的intel 600p nvme ssd 就順手來做個比較\n目標是看看有沒有可能直接用外接的SSD來跑postgresql\x3c\/p\x3e",
"inLanguage" : "en",
"author" : "Eric Chang",
"creator" : "Eric Chang",
"publisher": "Eric Chang",
"accountablePerson" : "Eric Chang",
"copyrightHolder" : "Eric Chang",
"copyrightYear" : "2019",
"datePublished": "2019-09-10 14:37:09 \x2b0800 CST",
"dateModified" : "2019-09-10 14:37:09 \x2b0800 CST",
"url" : "https:\/\/h.cowbay.org\/post\/bencmark-with-external-internal-nvme-ssd-and-external-sata-ssd\/",
"wordCount" : "1710",
"image" : "https://h.cowbay.orghttps://h.cowbay.org/images/post-default-9.jpg"",
"keywords" : [ ""postgresql"",""benchmark"",""nvme"","Blog" ]
}
</script>
<title>[筆記] 測試 USB 3.1 Gen2 NVME SSD 外接盒 &amp; 內建pci-e ssd &amp; 外接SATA SSD / Bencmark With External Internal Nvme Ssd and External Sata Ssd </title>
<meta name="description" content="some articles about job,food,passion sisters" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="all,follow">
<meta name="googlebot" content="index,follow,snippet,archive">
<link rel="stylesheet" id="ct-tracks-google-fonts-css" href="https://fonts.googleapis.com/css?family=Raleway%3A400%2C700&amp;subset=latin%2Clatin-ext&amp;ver=4.7.2" type="text/css" media="all">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<link href="https://h.cowbay.org/css/style.css?v=1597369724" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/custom.css?v=1597369724" rel="stylesheet" type='text/css' media='all'>
<link rel="shortcut icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
<link rel="icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
<script type="application/javascript">
var doNotTrack = false;
if (!doNotTrack) {
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-138954876-1', 'auto');
ga('send', 'pageview');
}
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
</head>
<body class="post-template-default single single-post single-format-standard ct-body singular singular-post not-front standard">
<div id="overflow-container" class="overflow-container">
<a class="skip-content" href="#main">Skip to content</a>
<header id="site-header" class="site-header" role="banner">
<div class='top-navigation'>
<div class='container'>
<div id="menu-secondary" class="menu-container menu-secondary" role="navigation">
<button id="toggle-secondary-navigation" class="toggle-secondary-navigation"><i class="fas fa-plus"></i></button>
<div class="menu">
<ul id="menu-secondary-items" class="menu-secondary-items">
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/"></a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/ansible">ansible</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/linux">linux</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/proxmox">proxmox</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/ps">ps</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/%E7%A2%8E%E5%BF%B5">碎念</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/%E7%AD%86%E8%A8%98">筆記</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/%E7%BE%A4%E6%9A%89">群暉</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/%E9%9B%9C%E5%BF%B5">雜念</a>
</li>
</ul>
</div>
</div>
<ul class="social-media-icons">
<li>
<a href="full%20Social%20profile%20url%20in%20facebook" data-animate-hover="pulse" class="facebook" target="_blank">
<i class="fab fa-facebook-square" title="facebook"></i>
<span class="screen-reader-text">facebook</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20googleplus" data-animate-hover="pulse" class="gplus" target="_blank">
<i class="fab fa-google-plus-g" title="googleplus"></i>
<span class="screen-reader-text">googleplus</span>
</a>
</li>
<li>
<a href="chang0206" data-animate-hover="pulse" class="twitter" target="_blank">
<i class="fab fa-twitter-square" title="twitter"></i>
<span class="screen-reader-text">twitter</span>
</a>
</li>
<li>
<a href="chang0206" data-animate-hover="pulse" class="instagram" target="_blank">
<i class="fab fa-instagram" title="instagram"></i>
<span class="screen-reader-text">instagram</span>
</a>
</li>
<li>
<a href="mailto:mc@hotshraingmy.info" data-animate-hover="pulse" class="email">
<i class="fas fa-envelope" title="email"></i>
<span class="screen-reader-text">email</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20linkedin" data-animate-hover="pulse" class="linkedin" target="_blank">
<i class="fab fa-linkedin-in" title="linkedin"></i>
<span class="screen-reader-text">linkedin</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20stackoverflow" data-animate-hover="pulse" class="stackoverflow" target="_blank">
<i class="fab fa-stack-overflow" title="stackoverflow"></i>
<span class="screen-reader-text">stackoverflow</span>
</a>
</li>
<li>
<a href="changchichung" data-animate-hover="pulse" class="github" target="_blank">
<i class="fab fa-github" title="github"></i>
<span class="screen-reader-text">github</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20pinterest" data-animate-hover="pulse" class="pinterest" target="_blank">
<i class="fab fa-pinterest" title="pinterest"></i>
<span class="screen-reader-text">pinterest</span>
</a>
</li>
<li>
<a href="https://h.cowbay.org/index.xml" data-animate-hover="pulse" class="rss" target="_blank">
<i class="fas fa-rss" title="rss"></i>
<span class="screen-reader-text">rss</span>
</a>
</li>
</ul></div>
</div>
<div class="container">
<div id="title-info" class="title-info">
<div id='site-title' class='site-title'>
<a href="/"> MC部落 </a>
</div>
</div>
<button id="toggle-navigation" class="toggle-navigation">
<i class="fas fa-bars"></i>
</button>
<div id="menu-primary-tracks" class="menu-primary-tracks"></div>
<div id="menu-primary" class="menu-container menu-primary" role="navigation">
<p class="site-description">Whats the Worst That Could Happen?</p>
<div class="menu">
<ul id="menu-primary-items" class="menu-primary-items">
<li class='menu-item menu-item-type-custom menu-item-object-custom '>
<a href="https://h.cowbay.org/">Home</a>
</li>
<li class='menu-item menu-item-type-post_type menu-item-object-page '>
<a href="https://h.cowbay.org/about/">About</a>
</li>
<li class='menu-item menu-item-type-post_type menu-item-object-page '>
<a href="https://h.cowbay.org/contact/">Get in touch</a>
</li>
</ul>
</div>
</div>
</div>
</header>
<div id="main" class="main" role="main">
<div id="loop-container" class="loop-container">
<div class="post type-post status-publish format-standard has-post-thumbnail hentry category-design tag-design tag-standard-2 tag-tagalicious tag-travel entry full-without-featured odd excerpt-1">
<div class='featured-image lazy lazy-bg-image' data-background="https://h.cowbay.org/images/post-default-9.jpg">
</div>
<div class="entry-meta">
<span class="date">10 September</span> <span> / </span>
<span class="author">
<a href="https://github.com/changchichung" title="Posts by Eric Chang" rel="author">Eric Chang</a>
</span>
<span class="category">
<span> / </span>
<a href="/categories/%E7%AD%86%E8%A8%98">筆記</a>
</span>
</div>
<div class='entry-header'>
<h1 class='entry-title'> [筆記] 測試 USB 3.1 Gen2 NVME SSD 外接盒 &amp; 內建pci-e ssd &amp; 外接SATA SSD / Bencmark With External Internal Nvme Ssd and External Sata Ssd</h1>
</div>
<div class="entry-container">
<div class="entry-content">
<article>
<p>前幾天在淘寶上買了個 SSK 的USB 3.1 Gen2 (type-c) NVME SSD 外接盒
手邊也剛好有一條多的intel 600p nvme ssd 就順手來做個比較
目標是看看有沒有可能直接用外接的SSD來跑postgresql</p>
<p>把600p 裝進去外接盒之後,就先來看一些簡單的資訊
不過沒想到用了幾個指令,都沒辦法辨別出正確的型號</p>
<h4 id="fdisk">fdisk</h4>
<p>沒有看到廠牌、型號</p>
<pre><code>2019-09-10 13:20:55 [minion@hqdc075 ~]$ sudo fdisk /dev/sdb
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sdb: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x59511d8e
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 500118191 500116144 238.5G 83 Linux
Command (m for help): q
</code></pre>
<h4 id="inxi">inxi</h4>
<p>內接的intel ssd 有看到不過外接的這顆SSD沒有model 可是可以看到序號
我在想這個序號應該是外接盒的序號而不是SSD的</p>
<pre><code>2019-09-10 13:21:51 [minion@hqdc075 ~]$ sudo inxi -Dxx
Drives: HDD Total Size: 640.2GB (11.3% used)
ID-1: /dev/nvme0n1 model: INTEL_SSDPEKKF256G7L size: 256.1GB serial: BTPYXXXXX firmware: 123P
ID-2: USB /dev/sda model: SD/MMC size: 128.1GB serial: 201205XXXXXX-0:0 temp: 0C
ID-3: USB /dev/sdb model: N/A size: 256.1GB serial: DF564XXXXXX:0 temp: 0C
2019-09-10 13:21:55 [minion@hqdc075 ~]$
</code></pre>
<h4 id="dmesg">dmesg</h4>
<p>一樣,也是認不出 SSD ,但是有抓到外接盒</p>
<pre><code>[16622.930915] hub 4-0:1.0: USB hub found
[16622.930926] hub 4-0:1.0: 2 ports detected
[16623.372533] usb 4-1: new SuperSpeedPlus Gen 2 USB device number 2 using xhci_hcd
[16623.393844] usb 4-1: New USB device found, idVendor=152d, idProduct=0562, bcdDevice= 2.04
[16623.393849] usb 4-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[16623.393853] usb 4-1: Product: SSK Storage
[16623.393856] usb 4-1: Manufacturer: SSK
[16623.393858] usb 4-1: SerialNumber: DF56419883B20
</code></pre>
<h4 id="直接測試吧">直接測試吧</h4>
<p>不看型號了,直接測試吧!先切好分割、格式化,然後掛載到 /mnt再用 dd 測試寫入
結果如下</p>
<pre><code>2019-09-10 13:24:03 [minion@hqdc075 ~]$ for i in {4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384};do sudo dd if=/dev/zero of=/mnt/&quot;$i&quot;k bs=&quot;$i&quot;k count=1k;done
1024+0 records in
1024+0 records out
4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.013719 s, 306 MB/s
1024+0 records in
1024+0 records out
8388608 bytes (8.4 MB, 8.0 MiB) copied, 0.0123268 s, 681 MB/s
1024+0 records in
1024+0 records out
16777216 bytes (17 MB, 16 MiB) copied, 0.0196891 s, 852 MB/s
1024+0 records in
1024+0 records out
33554432 bytes (34 MB, 32 MiB) copied, 0.0195221 s, 1.7 GB/s
1024+0 records in
1024+0 records out
67108864 bytes (67 MB, 64 MiB) copied, 0.0337692 s, 2.0 GB/s
1024+0 records in
1024+0 records out
134217728 bytes (134 MB, 128 MiB) copied, 0.0644939 s, 2.1 GB/s
1024+0 records in
1024+0 records out
268435456 bytes (268 MB, 256 MiB) copied, 0.131989 s, 2.0 GB/s
1024+0 records in
1024+0 records out
536870912 bytes (537 MB, 512 MiB) copied, 0.257682 s, 2.1 GB/s
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB, 1.0 GiB) copied, 0.529154 s, 2.0 GB/s
1024+0 records in
1024+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 3.48498 s, 616 MB/s
1024+0 records in
1024+0 records out
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 7.36899 s, 583 MB/s
1024+0 records in
1024+0 records out
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 73.1975 s, 117 MB/s
1024+0 records in
1024+0 records out
17179869184 bytes (17 GB, 16 GiB) copied, 153.142 s, 112 MB/s
2019-09-10 13:28:58 [minion@hqdc075 ~]$
</code></pre>
<p>可以發現,<strong>當寫入8G檔案的時候速度開始急遽下降</strong>
翻了一下google 看到這張表格</p>
<p><a href="https://www.anandtech.com/show/10850/the-intel-ssd-600p-512gb-review">https://www.anandtech.com/show/10850/the-intel-ssd-600p-512gb-review</a></p>
<p>intel 600p 256G 的SLC Cache 只有8.5GB
合理解釋了為什麼當寫入8G的檔案時速度會掉那麼慘跟SATA硬碟差不多了</p>
<h4 id="用iobench-測試看看">用iobench 測試看看</h4>
<p>得到一樣的結論8G左右就會把cache塞暴然後掉速</p>
<pre><code>2019-09-10 13:44:59 [changch@hqdc075 iobench]$ sudo ./iobench.sh --sync --dir /mnt --megabytes 8192
Target directory: /mnt
Testfile size: 8192 x 1 Megabyte
1. Write benchmark without cache
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 36.8695 s, 233 MB/s
2. Write benchmark with cache
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 64.1573 s, 134 MB/s
3. Read benchmark with dropped cache
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 9.21821 s, 932 MB/s
4. Read benchmark without cache drop
Start 1 of 5...
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 1.02253 s, 8.4 GB/s
Start 2 of 5...
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 0.832002 s, 10.3 GB/s
Start 3 of 5...
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 0.81194 s, 10.6 GB/s
Start 4 of 5...
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 0.821035 s, 10.5 GB/s
Start 5 of 5...
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 0.808803 s, 10.6 GB/s
Done.
2019-09-10 13:47:40 [changch@hqdc075 iobench]$
</code></pre>
<p>那如果不用8G的檔案大小來測試呢看起來是比較正常一點</p>
<pre><code>2019-09-10 13:47:40 [changch@hqdc075 iobench]$ sudo ./iobench.sh --sync --dir /mnt --megabytes 4096
Target directory: /mnt
Testfile size: 4096 x 1 Megabyte
1. Write benchmark without cache
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 7.55296 s, 569 MB/s
2. Write benchmark with cache
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 20.6237 s, 208 MB/s
3. Read benchmark with dropped cache
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 4.63622 s, 926 MB/s
4. Read benchmark without cache drop
Start 1 of 5...
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 0.518597 s, 8.3 GB/s
Start 2 of 5...
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 0.436877 s, 9.8 GB/s
Start 3 of 5...
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 0.437854 s, 9.8 GB/s
Start 4 of 5...
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 0.420224 s, 10.2 GB/s
Start 5 of 5...
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 0.431023 s, 10.0 GB/s
Done.
2019-09-10 13:50:09 [changch@hqdc075 iobench]$
</code></pre>
<h4 id="跑看看pgbench">跑看看pgbench ??</h4>
<p>試試看這次的目標,用 external nvme ssd 跑資料庫會不會跟放在本機的PCI-E SSD 有所差距?</p>
<h4 id="data-directory-in-internal-pcie-ssd">data_directory in internal pcie-ssd</h4>
<p><strong>initialize pgbench database</strong></p>
<pre><code>2019-09-10 13:52:35 [minion@hqdc075 ~]$ sudo su - postgres
postgres@hqdc075:~$ createdb pgbench
postgres@hqdc075:~$ pgbench -i -U postgres -s 10 pgbench
NOTICE: table &quot;pgbench_history&quot; does not exist, skipping
NOTICE: table &quot;pgbench_tellers&quot; does not exist, skipping
NOTICE: table &quot;pgbench_accounts&quot; does not exist, skipping
NOTICE: table &quot;pgbench_branches&quot; does not exist, skipping
creating tables...
100000 of 1000000 tuples (10%) done (elapsed 0.08 s, remaining 0.70 s)
200000 of 1000000 tuples (20%) done (elapsed 0.19 s, remaining 0.75 s)
300000 of 1000000 tuples (30%) done (elapsed 0.36 s, remaining 0.83 s)
400000 of 1000000 tuples (40%) done (elapsed 0.49 s, remaining 0.73 s)
500000 of 1000000 tuples (50%) done (elapsed 0.58 s, remaining 0.58 s)
600000 of 1000000 tuples (60%) done (elapsed 0.75 s, remaining 0.50 s)
700000 of 1000000 tuples (70%) done (elapsed 0.89 s, remaining 0.38 s)
800000 of 1000000 tuples (80%) done (elapsed 0.99 s, remaining 0.25 s)
900000 of 1000000 tuples (90%) done (elapsed 1.11 s, remaining 0.12 s)
1000000 of 1000000 tuples (100%) done (elapsed 1.27 s, remaining 0.00 s)
vacuum...
set primary keys...
done.
</code></pre>
<p><strong>run pgbench</strong></p>
<pre><code>postgres@hqdc075:~$ pgbench -t 10 -c 100 -S -U postgres pgbench
starting vacuum...end.
transaction type: &lt;builtin: select only&gt;
scaling factor: 10
query mode: simple
number of clients: 100
number of threads: 1
number of transactions per client: 10
number of transactions actually processed: 1000/1000
latency average = 32.118 ms
tps = 3113.559459 (including connections establishing)
tps = 3135.056341 (excluding connections establishing)
postgres@hqdc075:~$ pgbench -t 1000 -c 100 -S -U postgres pgbench
starting vacuum...end.
transaction type: &lt;builtin: select only&gt;
scaling factor: 10
query mode: simple
number of clients: 100
number of threads: 1
number of transactions per client: 1000
number of transactions actually processed: 100000/100000
latency average = 3.753 ms
tps = 26643.223990 (including connections establishing)
tps = 26659.061459 (excluding connections establishing)
</code></pre>
<h4 id="data-directory-in-external-nvme-ssd">data_directory in external NVME SSD</h4>
<p><strong>initialize pgbench database</strong></p>
<pre><code>postgres@hqdc075:~$ pgbench -i -U postgres -s 10 pgbench
creating tables...
100000 of 1000000 tuples (10%) done (elapsed 0.08 s, remaining 0.70 s)
200000 of 1000000 tuples (20%) done (elapsed 0.19 s, remaining 0.76 s)
300000 of 1000000 tuples (30%) done (elapsed 0.35 s, remaining 0.81 s)
400000 of 1000000 tuples (40%) done (elapsed 0.49 s, remaining 0.74 s)
500000 of 1000000 tuples (50%) done (elapsed 0.60 s, remaining 0.60 s)
600000 of 1000000 tuples (60%) done (elapsed 0.76 s, remaining 0.51 s)
700000 of 1000000 tuples (70%) done (elapsed 0.89 s, remaining 0.38 s)
800000 of 1000000 tuples (80%) done (elapsed 1.01 s, remaining 0.25 s)
900000 of 1000000 tuples (90%) done (elapsed 1.15 s, remaining 0.13 s)
1000000 of 1000000 tuples (100%) done (elapsed 1.32 s, remaining 0.00 s)
vacuum...
set primary keys...
done.
</code></pre>
<p><strong>run pgbench</strong>
可以看到兩邊的結果其實是差不多的,作為資料庫備份是一定沒有問題
至於能不能直接作為資料庫空間使用?我想也許可以嘗試看看..</p>
<pre><code>postgres@hqdc075:~$ pgbench -t 10 -c 100 -S -U postgres pgbench
starting vacuum...end.
transaction type: &lt;builtin: select only&gt;
scaling factor: 10
query mode: simple
number of clients: 100
number of threads: 1
number of transactions per client: 10
number of transactions actually processed: 1000/1000
latency average = 32.998 ms
tps = 3030.531670 (including connections establishing)
tps = 3051.744292 (excluding connections establishing)
postgres@hqdc075:~$ pgbench -t 1000 -c 100 -S -U postgres pgbench
starting vacuum...end.
transaction type: &lt;builtin: select only&gt;
scaling factor: 10
query mode: simple
number of clients: 100
number of threads: 1
number of transactions per client: 1000
number of transactions actually processed: 100000/100000
latency average = 3.758 ms
tps = 26610.771423 (including connections establishing)
tps = 26626.871871 (excluding connections establishing)
postgres@hqdc075:~$
</code></pre>
<p>update:</p>
<p>剛剛看了一下,發現這樣只有測試到 read (select only)
或許要找找看其他的測試方法</p>
<hr />
<p>接下來直接用 restore 測試</p>
<pre><code>#### restore 5G database with external nvme ssd
postgres@hqdc075:~$ createdb demo
postgres@hqdc075:~$ time psql demo &lt; /tmp/demo.sql
SET
...
ALTER TABLE
real 4m1.184s
user 0m2.894s
sys 0m0.504s
postgres@hqdc075:~$
</code></pre>
<h4 id="restore-5g-database-with-internal-pci-e-nvme-ssd">restore 5G database with internal pci-e nvme ssd</h4>
<pre><code>postgres@hqdc075:~$ dropdb demo
postgres@hqdc075:~$ createdb demo
postgres@hqdc075:~$ time psql demo &lt; /tmp/demo.sql
SET
...
ALTER TABLE
real 4m1.636s
user 0m2.909s
sys 0m0.612s
postgres@hqdc075:~$
</code></pre>
<p>看起來是沒有什麼區別,那如果是外接的 SATA SSD呢</p>
<hr />
<p>dmesg 看得到型號耶..</p>
<pre><code>[23995.478928] usb 2-4: new SuperSpeed Gen 1 USB device number 3 using xhci_hcd
[23995.506134] usb 2-4: New USB device found, idVendor=2109, idProduct=0715, bcdDevice= 3.36
[23995.506141] usb 2-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[23995.506145] usb 2-4: Product: 30848
[23995.506149] usb 2-4: Manufacturer: Ugreen
[23995.506153] usb 2-4: SerialNumber: 00000012526D
[23995.512813] scsi host2: uas
[23995.530161] scsi 2:0:0:0: Direct-Access SanDisk SDSSDXP240G R131 PQ: 0 ANSI: 6
[23995.531948] sd 2:0:0:0: Attached scsi generic sg2 type 0
[23995.533820] sd 2:0:0:0: [sdc] 468862128 512-byte logical blocks: (240 GB/224 GiB)
[23995.533986] sd 2:0:0:0: [sdc] Write Protect is off
[23995.533992] sd 2:0:0:0: [sdc] Mode Sense: 2f 00 00 00
[23995.534402] sd 2:0:0:0: [sdc] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[23995.534844] sd 2:0:0:0: [sdc] Optimal transfer size 33553920 bytes
[23995.540806] sdc:
[23995.544089] sd 2:0:0:0: [sdc] Attached SCSI disk
2019-09-10 14:24:54 [minion@hqdc075 ~]$
</code></pre>
<p><strong>restore 5G database with external sata SSD</strong></p>
<p>很意外的,速度居然還是差不多??</p>
<pre><code>postgres@hqdc075:~$ createdb demo
postgres@hqdc075:~$ time psql demo &lt; /tmp/demo.sql
SET
...
ALTER TABLE
real 4m9.950s
user 0m2.752s
sys 0m0.640s
postgres@hqdc075:~$
</code></pre>
<p><strong>run pgebnech</strong></p>
<p>這個差很多了tps 從前面的 26000 掉到剩下 2800 ,差十倍左右!</p>
<pre><code>postgres@hqdc075:~$ pgbench -t 10 -c 100 -S -U postgres pgbench
starting vacuum...end.
transaction type: &lt;builtin: select only&gt;
scaling factor: 10
query mode: simple
number of clients: 100
number of threads: 1
number of transactions per client: 10
number of transactions actually processed: 1000/1000
latency average = 35.267 ms
tps = 2835.526770 (including connections establishing)
tps = 2855.642604 (excluding connections establishing)
postgres@hqdc075:~$
</code></pre>
<p>疑問:</p>
<ol>
<li>什麼原因會讓外接/內建 nvme ssd 和外接SATA SSD 在 restore db時花了差不多時間但是 tps 差異那麼大呢?</li>
<li>這樣測試似乎沒有真正測出外接nvme ssd 跑資料庫時候的效能?</li>
</ol>
</article>
</div>
<div class='entry-meta-bottom'>
<div class="entry-categories"><p><span>Categories</span>
<a href="/categories/%E7%AD%86%E8%A8%98" title="View all posts in 筆記">筆記</a>
</p>
</div>
<div class="entry-tags"><p><span>Tags</span>
<a href="/tags/postgresql" title="View all posts tagged postgresql">postgresql</a>
<a href="/tags/benchmark" title="View all posts tagged benchmark">benchmark</a>
<a href="/tags/nvme" title="View all posts tagged nvme">nvme</a>
</p></div> </div>
<div class="author-meta">
<div class="author">
<img alt='Eric Chang' src="https://www.gravatar.com/avatar/23f8ed94e007297499ac8df1641b3ff5?s=100&d=identicon" class='avatar avatar-72 photo' height='72' width='72'>
<span>
Written by:<a href="https://github.com/changchichung" title="Posts by Eric Chang" rel="author">Eric Chang</a> </span>
</div>
<div class="bio">
<p>塵世裡一個迷途小書僮</p>
<a class="facebook" target="_blank"
href="full%20Social%20profile%20url%20in%20facebook">
<i class="fab fa-facebook-f"
title="facebook icon"></i>
</a>
<a class="googleplus" target="_blank"
href="full%20profile%20url%20in%20googleplus">
<i class="fab fa-google-plus-g"
title="googleplus icon"></i>
</a>
<a class="twitter" target="_blank"
href="chang0206">
<i class="fab fa-twitter-square"
title="twitter icon"></i>
</a>
<a class="linkedin" target="_blank"
href="full%20profile%20url%20in%20linkedin">
<i class="fab fa-linkedin"
title="linkedin icon"></i>
</a>
<a class="email" target="_blank"
href="mailto:mc@hotshraingmy.info">
<i class="fas fa-envelope"
title="email icon"></i>
</a>
<a class="instagram" target="_blank"
href="chang0206">
<i class="fab fa-instagram"
title="instagram icon"></i>
</a>
<a class="stackoverflow" target="_blank"
href="full%20profile%20url%20in%20stackoverflow">
<i class="fab fa-stack-overflow"
title="stackoverflow icon"></i>
</a>
<a class="github" target="_blank"
href="changchichung">
<i class="fab fa-github"
title="github icon"></i>
</a>
<a class="pinterest" target="_blank"
href="full%20profile%20url%20in%20pinterest">
<i class="fab fa-pinterest"
title="pinterest icon"></i>
</a>
</div>
</div>
</div>
</div>
<section id="comments" class="comments">
<div id="disqus_thread"></div>
<script type="application/javascript">
var disqus_config = function () {
};
(function() {
if (["localhost", "127.0.0.1"].indexOf(window.location.hostname) != -1) {
document.getElementById('disqus_thread').innerHTML = 'Disqus comments not available by default when the website is previewed locally.';
return;
}
var d = document, s = d.createElement('script'); s.async = true;
s.src = '//' + "h-cowbay-org-1" + '.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</section>
</div>
</div>
<footer id="site-footer" class="site-footer" role="contentinfo">
<h1>
<a href=""> MC部落 </a>
</h1>
<p class="site-description">Whats the Worst That Could Happen?</p>
<div id="menu-footer" class="menu-container menu-footer" role="navigation">
<div class="menu">
<ul id="menu-footer-items" class="menu-footer-items">
</ul>
</div> </div>
<ul class="social-media-icons">
<li>
<a class="facebook" target="_blank"
href="full%20Social%20profile%20url%20in%20facebook" >
<i class="fab fa-facebook-f" title="facebook"></i>
<span class="screen-reader-text">facebook</span>
</a>
</li>
<li>
<a class="googleplus" target="_blank"
href="full%20profile%20url%20in%20googleplus" >
<i class="fab fa-google-plus-g" title="googleplus"></i>
<span class="screen-reader-text">googleplus</span>
</a>
</li>
<li>
<a href="chang0206" class="twitter" target="_blank">
<i class="fab fa-twitter-square" title="twitter"></i>
<span class="screen-reader-text">twitter</span>
</a>
</li>
<li>
<a href="chang0206" class="instagram" target="_blank">
<i class="fab fa-instagram" title="instagram"></i>
<span class="screen-reader-text">instagram</span>
</a>
</li>
<li>
<a href="mailto:mc@hotshraingmy.info" class="email">
<i class="fas fa-envelope" title="email"></i>
<span class="screen-reader-text">email</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20linkedin" class="linkedin" target="_blank">
<i class="fab fa-linkedin-in" title="linkedin"></i>
<span class="screen-reader-text">linkedin</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20stackoverflow" class="stackoverflow" target="_blank">
<i class="fab fa-stack-overflow" title="stackoverflow"></i>
<span class="screen-reader-text">stackoverflow</span>
</a>
</li>
<li>
<a href="changchichung" class="github" target="_blank">
<i class="fab fa-github" title="github"></i>
<span class="screen-reader-text">github</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20pinterest" class="pinterest" target="_blank">
<i class="fab fa-pinterest" title="pinterest"></i>
<span class="screen-reader-text">pinterest</span>
</a>
</li>
<li>
<a href="https://h.cowbay.org/index.xml" data-animate-hover="pulse" class="rss" target="_blank">
<i class="fas fa-rss" title="rss"></i>
<span class="screen-reader-text">rss</span>
</a>
</li>
</ul> <div class="design-credit">
<p>&copy; 2018 Göran Svensson</p>
<p>Nederburg Hugo Theme by <a href="https://appernetic.io">Appernetic</a>.</p>
<p>A port of Tracks by Compete Themes.</p>
</div>
</footer>
</div>
<script src="https://h.cowbay.org/js/jquery.min.js"></script>
<script src="https://h.cowbay.org/js/jquerymigrate.js"></script>
<script src="https://h.cowbay.org/js/production.min.js?v=1597369724"></script>
</body>
</html>