SlideShare una empresa de Scribd logo
1 de 26
What Every Data Programmer  Needs to Know about Disks OSCON Data – July, 2011 - Portland Ted Dziuba @dozba tjdziuba@gmail.com Not proprietary or confidential. In fact, you’re risking a career by listening to me.
Who are you and why are you talking? First job: Like college but they pay you to go. A few years ago: Technical troll for The Register. Recently: Co-founder of Milo.com, local shopping engine. Present: Senior Technical Staff for eBay Local
The Linux Disk Abstraction Volume /mnt/volume File System xfs, ext Block Device HDD, HW RAID array
What happens when you read from a file? f = open(“/home/ted/not_pirated_movie.avi”, “rb”) avi_header = f.read(56) f.close() Disk controller user buffer page cache platter
What happens when you read from a file? Disk controller user buffer page cache ,[object Object]
Latency: 100 nanoseconds
Throughput: 12GB/sec on good hardwareplatter
What happens when you read from a file? Disk controller user buffer page cache ,[object Object]
Latency: 10 milliseconds
Throughput: 768 MB/sec on SATA 3
(Faster if you have a lot of money)platter
Sidebar: The Horror of a 10ms Seek Latency A disk read is 100,000 times slower than a memory read. 100 nanoseconds Time it takes you to write a really clever tweet 10 milliseconds Time it takes to write a novel, working full time
What happens when you write to a file? f = open(“/home/ted/nosql_database.csv”, “wb”) f.write(key) f.write(“,”) f.write(value) f.close() Disk controller user buffer page cache platter
What happens when you write to a file? f = open(“/home/ted/nosql_database.csv”, “wb”) f.write(key) f.write(“,”) f.write(value) f.close() Disk controller user buffer page cache platter You need to make this part happen Mark the page dirty, call it a day and go have a smoke.
Aside: Stick your finger in the Linux Page Cache Pre-Linux 2.6 used “pdflush”, now per-Backing Device Info (BDI) flush threads Dirty pages: grep –i “dirty” /proc/meminfo /proc/sys/vmLove: ,[object Object]
dirty_ratio: flush after some percent of memory is used
dirty_writeback_centisecs: how often to wake up and start flushingClear your page cache: echo 1 > /proc/sys/vm/drop_caches Crusty sysadmin’s hail-Mary pass: sync; sync; sync
Fsync: force a flush to disk f = open(“/home/ted/nosql_database.csv”, “wb”) f.write(key) f.write(“,”) f.write(value) os.fsync(f.fileno()) f.close() Disk controller user buffer page cache platter Also note, fsync() has a cousin, fdatasync() that does not sync metadata.
Aside: point and laugh at MongoDB Mongo’s “fsync” command: > db.runCommand({fsync:1,async:true});  wat. Also supports “journaling”, like a WAL in the SQL world, however… ,[object Object]
It’s not enabled by default.,[object Object]
Fsync: bitter lies platter …it’s a cache! Disk controller page cache ,[object Object]
Writeback is the demon,[object Object]
(Just dropped in) to see what condition your caches are in A Good Server platter Writethrough cache on controller Writethrough cache on disk Disk controller
(Just dropped in) to see what condition your caches are in An Even Better Server platter Battery-backedwriteback cache on controller Writethrough cache on disk Disk controller
(Just dropped in) to see what condition your caches are in The Demon Setup platter Battery-backed writeback cache or Writethrough cache Writeback cache on disk Disk controller
Disks in a virtual environment The Trail of Tears to the Platter Host page cache Virtual controller user buffer page cache Physical controller Hypervisor platter

Más contenido relacionado

La actualidad más candente

Get Your Insecure PostgreSQL Passwords to SCRAM
Get Your Insecure PostgreSQL Passwords to SCRAMGet Your Insecure PostgreSQL Passwords to SCRAM
Get Your Insecure PostgreSQL Passwords to SCRAM
Jonathan Katz
 
Filesystem Comparison: NFS vs GFS2 vs OCFS2
Filesystem Comparison: NFS vs GFS2 vs OCFS2Filesystem Comparison: NFS vs GFS2 vs OCFS2
Filesystem Comparison: NFS vs GFS2 vs OCFS2
Giuseppe Paterno'
 

La actualidad más candente (20)

忙しい人の5分で分かるMesos入門 - Mesos って何だ?
忙しい人の5分で分かるMesos入門 - Mesos って何だ?忙しい人の5分で分かるMesos入門 - Mesos って何だ?
忙しい人の5分で分かるMesos入門 - Mesos って何だ?
 
Tame the small files problem and optimize data layout for streaming ingestion...
Tame the small files problem and optimize data layout for streaming ingestion...Tame the small files problem and optimize data layout for streaming ingestion...
Tame the small files problem and optimize data layout for streaming ingestion...
 
RocksDB Performance and Reliability Practices
RocksDB Performance and Reliability PracticesRocksDB Performance and Reliability Practices
RocksDB Performance and Reliability Practices
 
コンテナ環境でJavaイメージを小さくする方法!
コンテナ環境でJavaイメージを小さくする方法!コンテナ環境でJavaイメージを小さくする方法!
コンテナ環境でJavaイメージを小さくする方法!
 
LXC, Docker, security: is it safe to run applications in Linux Containers?
LXC, Docker, security: is it safe to run applications in Linux Containers?LXC, Docker, security: is it safe to run applications in Linux Containers?
LXC, Docker, security: is it safe to run applications in Linux Containers?
 
15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ
15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ
15分でお届けする Elastic Stack on Azure 設計・構築ノウハウ
 
Monitoring kubernetes with prometheus
Monitoring kubernetes with prometheusMonitoring kubernetes with prometheus
Monitoring kubernetes with prometheus
 
Best practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability TutorialBest practices for MySQL High Availability Tutorial
Best practices for MySQL High Availability Tutorial
 
Get Your Insecure PostgreSQL Passwords to SCRAM
Get Your Insecure PostgreSQL Passwords to SCRAMGet Your Insecure PostgreSQL Passwords to SCRAM
Get Your Insecure PostgreSQL Passwords to SCRAM
 
Filesystem Comparison: NFS vs GFS2 vs OCFS2
Filesystem Comparison: NFS vs GFS2 vs OCFS2Filesystem Comparison: NFS vs GFS2 vs OCFS2
Filesystem Comparison: NFS vs GFS2 vs OCFS2
 
ClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and howClickHouse Monitoring 101: What to monitor and how
ClickHouse Monitoring 101: What to monitor and how
 
MySQL Group Replication - HandsOn Tutorial
MySQL Group Replication - HandsOn TutorialMySQL Group Replication - HandsOn Tutorial
MySQL Group Replication - HandsOn Tutorial
 
Linux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old SecretsLinux Performance Analysis: New Tools and Old Secrets
Linux Performance Analysis: New Tools and Old Secrets
 
Linux の hugepage の開発動向
Linux の hugepage の開発動向Linux の hugepage の開発動向
Linux の hugepage の開発動向
 
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdfDeep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
Deep Dive on ClickHouse Sharding and Replication-2202-09-22.pdf
 
BPF - in-kernel virtual machine
BPF - in-kernel virtual machineBPF - in-kernel virtual machine
BPF - in-kernel virtual machine
 
Supporting Apache HBase : Troubleshooting and Supportability Improvements
Supporting Apache HBase : Troubleshooting and Supportability ImprovementsSupporting Apache HBase : Troubleshooting and Supportability Improvements
Supporting Apache HBase : Troubleshooting and Supportability Improvements
 
High Availability PostgreSQL on OpenShift...and more!
High Availability PostgreSQL on OpenShift...and more!High Availability PostgreSQL on OpenShift...and more!
High Availability PostgreSQL on OpenShift...and more!
 
Seastore: Next Generation Backing Store for Ceph
Seastore: Next Generation Backing Store for CephSeastore: Next Generation Backing Store for Ceph
Seastore: Next Generation Backing Store for Ceph
 
What is in a Lucene index?
What is in a Lucene index?What is in a Lucene index?
What is in a Lucene index?
 

Similar a What every data programmer needs to know about disks

Алексей Лесовский "Тюнинг Linux для баз данных. "
Алексей Лесовский "Тюнинг Linux для баз данных. "Алексей Лесовский "Тюнинг Linux для баз данных. "
Алексей Лесовский "Тюнинг Linux для баз данных. "
Tanya Denisyuk
 

Similar a What every data programmer needs to know about disks (20)

Linux Recovery
Linux RecoveryLinux Recovery
Linux Recovery
 
Memory management in Linux
Memory management in LinuxMemory management in Linux
Memory management in Linux
 
Let Me Pick Your Brain - Remote Forensics in Hardened Environments
Let Me Pick Your Brain - Remote Forensics in Hardened EnvironmentsLet Me Pick Your Brain - Remote Forensics in Hardened Environments
Let Me Pick Your Brain - Remote Forensics in Hardened Environments
 
Vmfs
VmfsVmfs
Vmfs
 
Logical volume manager xfs
Logical volume manager xfsLogical volume manager xfs
Logical volume manager xfs
 
Hardware
HardwareHardware
Hardware
 
Data hiding and finding on Linux
Data hiding and finding on LinuxData hiding and finding on Linux
Data hiding and finding on Linux
 
Tuning Linux for Databases.
Tuning Linux for Databases.Tuning Linux for Databases.
Tuning Linux for Databases.
 
Алексей Лесовский "Тюнинг Linux для баз данных. "
Алексей Лесовский "Тюнинг Linux для баз данных. "Алексей Лесовский "Тюнинг Linux для баз данных. "
Алексей Лесовский "Тюнинг Linux для баз данных. "
 
Live memory forensics
Live memory forensicsLive memory forensics
Live memory forensics
 
Clear cache memory
Clear cache memoryClear cache memory
Clear cache memory
 
Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)Deployment Strategies (Mongo Austin)
Deployment Strategies (Mongo Austin)
 
MySQL Oslayer performace optimization
MySQL  Oslayer performace optimizationMySQL  Oslayer performace optimization
MySQL Oslayer performace optimization
 
Hadoop architecture (Delhi Hadoop User Group Meetup 10 Sep 2011)
Hadoop architecture (Delhi Hadoop User Group Meetup 10 Sep 2011)Hadoop architecture (Delhi Hadoop User Group Meetup 10 Sep 2011)
Hadoop architecture (Delhi Hadoop User Group Meetup 10 Sep 2011)
 
FreeBSD Portscamp, Kuala Lumpur 2016
FreeBSD Portscamp, Kuala Lumpur 2016FreeBSD Portscamp, Kuala Lumpur 2016
FreeBSD Portscamp, Kuala Lumpur 2016
 
Bringing up Android on your favorite X86 Workstation or VM (AnDevCon Boston, ...
Bringing up Android on your favorite X86 Workstation or VM (AnDevCon Boston, ...Bringing up Android on your favorite X86 Workstation or VM (AnDevCon Boston, ...
Bringing up Android on your favorite X86 Workstation or VM (AnDevCon Boston, ...
 
Recipe of a linux Live CD (archived)
Recipe of a linux Live CD (archived)Recipe of a linux Live CD (archived)
Recipe of a linux Live CD (archived)
 
Hadoop Architecture
Hadoop ArchitectureHadoop Architecture
Hadoop Architecture
 
Linux filesystemhierarchy
Linux filesystemhierarchyLinux filesystemhierarchy
Linux filesystemhierarchy
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
 

Más de iammutex

Realtime hadoopsigmod2011
Realtime hadoopsigmod2011Realtime hadoopsigmod2011
Realtime hadoopsigmod2011
iammutex
 

Más de iammutex (20)

Scaling Instagram
Scaling InstagramScaling Instagram
Scaling Instagram
 
Redis深入浅出
Redis深入浅出Redis深入浅出
Redis深入浅出
 
深入了解Redis
深入了解Redis深入了解Redis
深入了解Redis
 
NoSQL误用和常见陷阱分析
NoSQL误用和常见陷阱分析NoSQL误用和常见陷阱分析
NoSQL误用和常见陷阱分析
 
MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用MongoDB 在盛大大数据量下的应用
MongoDB 在盛大大数据量下的应用
 
8 minute MongoDB tutorial slide
8 minute MongoDB tutorial slide8 minute MongoDB tutorial slide
8 minute MongoDB tutorial slide
 
skip list
skip listskip list
skip list
 
Thoughts on Transaction and Consistency Models
Thoughts on Transaction and Consistency ModelsThoughts on Transaction and Consistency Models
Thoughts on Transaction and Consistency Models
 
Rethink db&tokudb调研测试报告
Rethink db&tokudb调研测试报告Rethink db&tokudb调研测试报告
Rethink db&tokudb调研测试报告
 
redis 适用场景与实现
redis 适用场景与实现redis 适用场景与实现
redis 适用场景与实现
 
Introduction to couchdb
Introduction to couchdbIntroduction to couchdb
Introduction to couchdb
 
Ooredis
OoredisOoredis
Ooredis
 
Ooredis
OoredisOoredis
Ooredis
 
redis运维之道
redis运维之道redis运维之道
redis运维之道
 
Realtime hadoopsigmod2011
Realtime hadoopsigmod2011Realtime hadoopsigmod2011
Realtime hadoopsigmod2011
 
[译]No sql生态系统
[译]No sql生态系统[译]No sql生态系统
[译]No sql生态系统
 
Couchdb + Membase = Couchbase
Couchdb + Membase = CouchbaseCouchdb + Membase = Couchbase
Couchdb + Membase = Couchbase
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
Hadoop introduction berlin buzzwords 2011
Hadoop introduction   berlin buzzwords 2011Hadoop introduction   berlin buzzwords 2011
Hadoop introduction berlin buzzwords 2011
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

What every data programmer needs to know about disks

  • 1. What Every Data Programmer Needs to Know about Disks OSCON Data – July, 2011 - Portland Ted Dziuba @dozba tjdziuba@gmail.com Not proprietary or confidential. In fact, you’re risking a career by listening to me.
  • 2. Who are you and why are you talking? First job: Like college but they pay you to go. A few years ago: Technical troll for The Register. Recently: Co-founder of Milo.com, local shopping engine. Present: Senior Technical Staff for eBay Local
  • 3. The Linux Disk Abstraction Volume /mnt/volume File System xfs, ext Block Device HDD, HW RAID array
  • 4. What happens when you read from a file? f = open(“/home/ted/not_pirated_movie.avi”, “rb”) avi_header = f.read(56) f.close() Disk controller user buffer page cache platter
  • 5.
  • 7. Throughput: 12GB/sec on good hardwareplatter
  • 8.
  • 11. (Faster if you have a lot of money)platter
  • 12. Sidebar: The Horror of a 10ms Seek Latency A disk read is 100,000 times slower than a memory read. 100 nanoseconds Time it takes you to write a really clever tweet 10 milliseconds Time it takes to write a novel, working full time
  • 13. What happens when you write to a file? f = open(“/home/ted/nosql_database.csv”, “wb”) f.write(key) f.write(“,”) f.write(value) f.close() Disk controller user buffer page cache platter
  • 14. What happens when you write to a file? f = open(“/home/ted/nosql_database.csv”, “wb”) f.write(key) f.write(“,”) f.write(value) f.close() Disk controller user buffer page cache platter You need to make this part happen Mark the page dirty, call it a day and go have a smoke.
  • 15.
  • 16. dirty_ratio: flush after some percent of memory is used
  • 17. dirty_writeback_centisecs: how often to wake up and start flushingClear your page cache: echo 1 > /proc/sys/vm/drop_caches Crusty sysadmin’s hail-Mary pass: sync; sync; sync
  • 18. Fsync: force a flush to disk f = open(“/home/ted/nosql_database.csv”, “wb”) f.write(key) f.write(“,”) f.write(value) os.fsync(f.fileno()) f.close() Disk controller user buffer page cache platter Also note, fsync() has a cousin, fdatasync() that does not sync metadata.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23. (Just dropped in) to see what condition your caches are in A Good Server platter Writethrough cache on controller Writethrough cache on disk Disk controller
  • 24. (Just dropped in) to see what condition your caches are in An Even Better Server platter Battery-backedwriteback cache on controller Writethrough cache on disk Disk controller
  • 25. (Just dropped in) to see what condition your caches are in The Demon Setup platter Battery-backed writeback cache or Writethrough cache Writeback cache on disk Disk controller
  • 26. Disks in a virtual environment The Trail of Tears to the Platter Host page cache Virtual controller user buffer page cache Physical controller Hypervisor platter
  • 27.
  • 30. How are the caches configured?
  • 31. How big are the caches?
  • 35. Aside: Amazon EBS MySQL Amazon EBS Please stop doing this.
  • 36. What’s Killing That Box? ted@u235:~$ iostat -x Linux 2.6.32-24-generic (u235) 07/25/2011 _x86_64_ (8 CPU) avg-cpu: %user %nice %system %iowait %steal %idle 0.15 0.14 0.05 0.00 0.00 99.66 Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz%util sda 0.00 3.27 0.01 2.38 0.58 45.23 19.21 0.24
  • 37.
  • 38. Negligible seek time vs 10ms seek time
  • 39.
  • 44.
  • 48.

Notas del editor

  1. Note that the page is actually in memory twice. Mmaped files fix this, but it’s beyond the scope of this discussion.Also this is why read performance on a lot of memory only NoSQL databases beats disk-backed SQL. Duh.
  2. Equate 100 nanoseconds to about 100 seconds. Then 10 milliseconds is about 3 months.
  3. This is where a lot of NoSQL databases get their performance, but more on that in a few minutes.
  4. There are threads that wake up every now and then to flush pages to disk.
  5. Fsync blocks until the data has been written to disk.
  6. With a battery-backed RAID controller, fsync can return very quickly with little risk of data loss.
  7. You need to dive into your vendor’s control tool to find this out.
  8. VMWare server is faithful to fsync, VMWare workstation is not. Xen usually queues I/O requests after they have been issued. The point is that you have no way of knowing. Your visibility of what happens to your data after you write or fsync ends at the hypervisor.
  9. Newer intel chips have the northbridge controller on-die. Southbridge bandwidth is usually <= 10GB/sec, and you are sharing this with other customers’ network and disk I/O. That, and you may be sharing drive spindles.
  10. EBS lies about the result of fsync. This is why Reddit is down all the time. You have been warned.
  11. EBS lies about the result of fsync. This is why Reddit is down all the time. You have been warned.