Why does `/dev/shm` on an EC2 instance have I/O throughput comparable to an EBS drive?

Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I recently learned about the convenient "shared memory" file system at /dev/shm. I wanted to see if I could use this to speed up a sometimes-disk-bound program that writes to and reads from a directory, so I ran a little experiment on an EC2 instance (c4.8xlarge running Ubuntu 16.04):
$ time yes asdfjkl | head -1000000000 > /mnt/fake.txt
real 0m21.381s
$ time yes asdfjkl | head -1000000000 > /dev/shm/fake.txt
real 0m20.266s
$ time yes asdfjkl | head -1000000000 > /dev/null
real 0m14.334s
The EC2 instance seems to have comparable write throughput to /dev/shm/ as it does to an EBS drive, which was surprising. htop indicates that the machine isn't using swap space in order to write to /dev/shm. The noticeably faster write to /dev/null in the third case indicates that I'm probably not bound by some other factor (e.g. CPU via the implementation of yes) in the first two cases.
I ran the same experiment on my personal computer -- enough memory that /dev/shm can hold 7.5 GB of asdfjkln by default, I can dig up more hardware details if anyone thinks they'll matter -- also running Ubuntu 16.04:
$ time yes asdfjkl | head -1000000000 > /mnt/fake.txt
real 0m36.520s
$ time yes asdfjkl | head -1000000000 > /dev/shm/fake.txt
real 0m12.516s
$ time yes asdfjkl | head -1000000000 > /dev/null
real 0m11.252s
This is much closer to what I expected. Read throughput (writing to /dev/null) on both machines and from both file systems is roughly proportional to write throughput in the corresponding case.
Two other observations, which I don't know quite how to interpret:
- On the EC2 instance,
htopindicates memory usage comparable to the size of/dev/shm/fake.txtonce it's written, while on my desktop, it does not. - On the EC2 instance, concurrent disk write congestion appears to slow down a write to shared memory by an amount comparable to how much the writes to disk were slowed down, while on my desktop, it does not.
amazon-ec2 shared-memory
add a comment |Â
up vote
3
down vote
favorite
I recently learned about the convenient "shared memory" file system at /dev/shm. I wanted to see if I could use this to speed up a sometimes-disk-bound program that writes to and reads from a directory, so I ran a little experiment on an EC2 instance (c4.8xlarge running Ubuntu 16.04):
$ time yes asdfjkl | head -1000000000 > /mnt/fake.txt
real 0m21.381s
$ time yes asdfjkl | head -1000000000 > /dev/shm/fake.txt
real 0m20.266s
$ time yes asdfjkl | head -1000000000 > /dev/null
real 0m14.334s
The EC2 instance seems to have comparable write throughput to /dev/shm/ as it does to an EBS drive, which was surprising. htop indicates that the machine isn't using swap space in order to write to /dev/shm. The noticeably faster write to /dev/null in the third case indicates that I'm probably not bound by some other factor (e.g. CPU via the implementation of yes) in the first two cases.
I ran the same experiment on my personal computer -- enough memory that /dev/shm can hold 7.5 GB of asdfjkln by default, I can dig up more hardware details if anyone thinks they'll matter -- also running Ubuntu 16.04:
$ time yes asdfjkl | head -1000000000 > /mnt/fake.txt
real 0m36.520s
$ time yes asdfjkl | head -1000000000 > /dev/shm/fake.txt
real 0m12.516s
$ time yes asdfjkl | head -1000000000 > /dev/null
real 0m11.252s
This is much closer to what I expected. Read throughput (writing to /dev/null) on both machines and from both file systems is roughly proportional to write throughput in the corresponding case.
Two other observations, which I don't know quite how to interpret:
- On the EC2 instance,
htopindicates memory usage comparable to the size of/dev/shm/fake.txtonce it's written, while on my desktop, it does not. - On the EC2 instance, concurrent disk write congestion appears to slow down a write to shared memory by an amount comparable to how much the writes to disk were slowed down, while on my desktop, it does not.
amazon-ec2 shared-memory
2
You really need to ask Amazon. They won't tell you, but probably nobody else can.
â Michael Homer
Jan 24 at 5:36
2
You would improve the question by adding details of the swap usage for both systems to it.
â JdeBP
Jan 24 at 6:29
1
/dev/zeromight (?) be a better data source. Interesting question.
â Michael - sqlbot
Jan 24 at 13:11
@JdeBP neither machine is using swap, clarified in the question. Thanks
â James
Jan 24 at 13:40
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I recently learned about the convenient "shared memory" file system at /dev/shm. I wanted to see if I could use this to speed up a sometimes-disk-bound program that writes to and reads from a directory, so I ran a little experiment on an EC2 instance (c4.8xlarge running Ubuntu 16.04):
$ time yes asdfjkl | head -1000000000 > /mnt/fake.txt
real 0m21.381s
$ time yes asdfjkl | head -1000000000 > /dev/shm/fake.txt
real 0m20.266s
$ time yes asdfjkl | head -1000000000 > /dev/null
real 0m14.334s
The EC2 instance seems to have comparable write throughput to /dev/shm/ as it does to an EBS drive, which was surprising. htop indicates that the machine isn't using swap space in order to write to /dev/shm. The noticeably faster write to /dev/null in the third case indicates that I'm probably not bound by some other factor (e.g. CPU via the implementation of yes) in the first two cases.
I ran the same experiment on my personal computer -- enough memory that /dev/shm can hold 7.5 GB of asdfjkln by default, I can dig up more hardware details if anyone thinks they'll matter -- also running Ubuntu 16.04:
$ time yes asdfjkl | head -1000000000 > /mnt/fake.txt
real 0m36.520s
$ time yes asdfjkl | head -1000000000 > /dev/shm/fake.txt
real 0m12.516s
$ time yes asdfjkl | head -1000000000 > /dev/null
real 0m11.252s
This is much closer to what I expected. Read throughput (writing to /dev/null) on both machines and from both file systems is roughly proportional to write throughput in the corresponding case.
Two other observations, which I don't know quite how to interpret:
- On the EC2 instance,
htopindicates memory usage comparable to the size of/dev/shm/fake.txtonce it's written, while on my desktop, it does not. - On the EC2 instance, concurrent disk write congestion appears to slow down a write to shared memory by an amount comparable to how much the writes to disk were slowed down, while on my desktop, it does not.
amazon-ec2 shared-memory
I recently learned about the convenient "shared memory" file system at /dev/shm. I wanted to see if I could use this to speed up a sometimes-disk-bound program that writes to and reads from a directory, so I ran a little experiment on an EC2 instance (c4.8xlarge running Ubuntu 16.04):
$ time yes asdfjkl | head -1000000000 > /mnt/fake.txt
real 0m21.381s
$ time yes asdfjkl | head -1000000000 > /dev/shm/fake.txt
real 0m20.266s
$ time yes asdfjkl | head -1000000000 > /dev/null
real 0m14.334s
The EC2 instance seems to have comparable write throughput to /dev/shm/ as it does to an EBS drive, which was surprising. htop indicates that the machine isn't using swap space in order to write to /dev/shm. The noticeably faster write to /dev/null in the third case indicates that I'm probably not bound by some other factor (e.g. CPU via the implementation of yes) in the first two cases.
I ran the same experiment on my personal computer -- enough memory that /dev/shm can hold 7.5 GB of asdfjkln by default, I can dig up more hardware details if anyone thinks they'll matter -- also running Ubuntu 16.04:
$ time yes asdfjkl | head -1000000000 > /mnt/fake.txt
real 0m36.520s
$ time yes asdfjkl | head -1000000000 > /dev/shm/fake.txt
real 0m12.516s
$ time yes asdfjkl | head -1000000000 > /dev/null
real 0m11.252s
This is much closer to what I expected. Read throughput (writing to /dev/null) on both machines and from both file systems is roughly proportional to write throughput in the corresponding case.
Two other observations, which I don't know quite how to interpret:
- On the EC2 instance,
htopindicates memory usage comparable to the size of/dev/shm/fake.txtonce it's written, while on my desktop, it does not. - On the EC2 instance, concurrent disk write congestion appears to slow down a write to shared memory by an amount comparable to how much the writes to disk were slowed down, while on my desktop, it does not.
amazon-ec2 shared-memory
edited Jan 24 at 13:40
asked Jan 24 at 4:43
James
163
163
2
You really need to ask Amazon. They won't tell you, but probably nobody else can.
â Michael Homer
Jan 24 at 5:36
2
You would improve the question by adding details of the swap usage for both systems to it.
â JdeBP
Jan 24 at 6:29
1
/dev/zeromight (?) be a better data source. Interesting question.
â Michael - sqlbot
Jan 24 at 13:11
@JdeBP neither machine is using swap, clarified in the question. Thanks
â James
Jan 24 at 13:40
add a comment |Â
2
You really need to ask Amazon. They won't tell you, but probably nobody else can.
â Michael Homer
Jan 24 at 5:36
2
You would improve the question by adding details of the swap usage for both systems to it.
â JdeBP
Jan 24 at 6:29
1
/dev/zeromight (?) be a better data source. Interesting question.
â Michael - sqlbot
Jan 24 at 13:11
@JdeBP neither machine is using swap, clarified in the question. Thanks
â James
Jan 24 at 13:40
2
2
You really need to ask Amazon. They won't tell you, but probably nobody else can.
â Michael Homer
Jan 24 at 5:36
You really need to ask Amazon. They won't tell you, but probably nobody else can.
â Michael Homer
Jan 24 at 5:36
2
2
You would improve the question by adding details of the swap usage for both systems to it.
â JdeBP
Jan 24 at 6:29
You would improve the question by adding details of the swap usage for both systems to it.
â JdeBP
Jan 24 at 6:29
1
1
/dev/zero might (?) be a better data source. Interesting question.â Michael - sqlbot
Jan 24 at 13:11
/dev/zero might (?) be a better data source. Interesting question.â Michael - sqlbot
Jan 24 at 13:11
@JdeBP neither machine is using swap, clarified in the question. Thanks
â James
Jan 24 at 13:40
@JdeBP neither machine is using swap, clarified in the question. Thanks
â James
Jan 24 at 13:40
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f419255%2fwhy-does-dev-shm-on-an-ec2-instance-have-i-o-throughput-comparable-to-an-ebs%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
2
You really need to ask Amazon. They won't tell you, but probably nobody else can.
â Michael Homer
Jan 24 at 5:36
2
You would improve the question by adding details of the swap usage for both systems to it.
â JdeBP
Jan 24 at 6:29
1
/dev/zeromight (?) be a better data source. Interesting question.â Michael - sqlbot
Jan 24 at 13:11
@JdeBP neither machine is using swap, clarified in the question. Thanks
â James
Jan 24 at 13:40