I was evaluating Azure and it appears the Ubuntu VM I created has unexpectedly low disk performance. I noticed this because the database import took much longer compare to another Rackspace VM I'm using. And I'm not sure whether there is any important configurations that I missed or is it just I'm looking at the disk performance in the wrong way. Here are my tests and the results:
Standard A1 VM (1 core, 1.75GB memory, Ubuntu 12.04 LTS)
sudo hdparm -tT /dev/sdb
Timing cached reads: 6892 MB in 2.00 seconds = 3451.31 MB/sec
Timing buffered disk reads: 40 MB in 3.37 seconds = 11.88 MB/sec
sudo hdparm -t --direct /dev/sdb
Timing O_DIRECT disk reads: 46 MB in 3.74 seconds = 12.29 MB/sec
sudo dd if=/dev/zero of=/mnt/test bs=8k count=200000; sudo rm -f /mnt/test
1638400000 bytes (1.6 GB) copied, 246.32 s, 6.7 MB/s
As comparison, my other VM on Rackspace (4 vCPU, 1GB memory, Ubuntu 12.04 LTS) has the following results:
sudo hdparm -tT /dev/xvda
Timing cached reads: 5960 MB in 1.99 seconds = 2990.32 MB/sec
Timing buffered disk reads: 200 MB in 3.05 seconds = 65.66 MB/sec
sudo hdparm -t --direct /dev/xvda
Timing O_DIRECT disk reads: 162 MB in 3.12 seconds = 52.00 MB/sec
sudo dd if=/dev/zero of=test bs=8k count=200000; sudo rm -f test
1638400000 bytes (1.6 GB) copied, 13.7139 s, 119 MB/s
Although the Azure VM has better cached read performance, its disk read (both buffered and direct) is quite slow, and disk write (or copy) is way worse. As Linux VM on Azure does not have swap file configured by default, I manually created a 5GB swap file (on /dev/sdb) but it does not seem to help.
Then I did one more around of testing on Azure using a Standard D3 VM (4 cores, 14GB memory, Ubuntu 12.04 LTS). When executing the commands above on /dev/sdb the performance was amazing, I guess because of local SSD? However when I attach an additional disk to that D3 VM and run the same commands on the newly created /dev/sdc partition (ext4), the results are just as bad as the A1 instance.
Not sure if this is the best way to test disk performance in Linux. But it is pretty noticeable that the Azure VM is much slower when restoring database backup. Microsoft Azure support page suggests that we could ask question here with the "azure" tag, so ... Any comments is welcomed.
I removed the disk that I attached to the Standard D3 VM earlier, then followed the same process and attached a new one. Somehow the newly attached disk has much better performance as showing below
Standard D3 VM (4 cores, 14GB memory, Ubuntu 12.04 LTS)
sudo hdparm -tT /dev/sdc
Timing cached reads: 13054 MB in 1.99 seconds = 6546.15 MB/sec
Timing buffered disk reads: 68 MB in 3.01 seconds = 22.57 MB/sec
sudo hdparm -t --direct /dev/sdc
Timing O_DIRECT disk reads: 98 MB in 3.03 seconds = 32.35 MB/sec
sudo dd if=/dev/zero of=/mnt/test bs=8k count=200000; sudo rm -f /mnt/test
1638400000 bytes (1.6 GB) copied, 1.5689 s, 1.0 GB/s
Not exactly sure why. But my problem does not exist any more. Therefore closing this question.
D series are SSD based. Your /mnt or /mnt/resource on an A would also be SSD based and local to the server, but is not persistent. Cloud vendors have guidance on setting up striping or RAID0 (or 10) to increase IOPS. For Azure, I suggest taking a look at this guide that is designed for MySQL but covers from the disks up.
Related
I am trying to get performance of mounted Sd card to my board and i am using Iozone tool to do that but i am getting starnge results:
command:
# mount /dev/mmcblk2p2 /mnt/SD
# cd /mnt/SD
# iozone -a -s 10M -r 5K -w -e
results:
random random bkwd record stride
KB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
10240 5 4283 4136 68681 378738 337652 3871 133905 96074 216912 4122 5013 364024 376181
the results are in Kbytes that's mean the speed random read is 300MB/s ??
my card is class 4 normally the write speed is 4 MB/s and the reading speed is not very different to this value ??
iozone -a -s 10M -r 5K -w -e
random random bkwd record stride
KB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
10240 5 4283 4136 68681 378738 337652 3871 133905 96074 216912 4122 5013 364024 376181
Yes, your results are in kilobyte/s (KB/s; don't use -s silent option and iozone will say it Output is in kBytes/sec), and yes, there was 380 MB/s for "reread" speed (and 200 MB/s for read after reread?). But reread may be not the speed of your block device (SD card/HDD/SSD) if you test set (10 MB) is smaller than your RAM amount (it is).
Most OS (and Linux too) have software cache-in-RAM for filesystems and block devices. When you access some block for first time (since boot), it will be read from the device and stored in Page Cache of OS. Next access (read) of this block will be served directly from RAM, not from the device itself (unless O_DIRECT option was used in I/O operation, -I option of iozone).
So, your test run is incorrect. Read man page of iozone before use: http://linux.die.net/man/1/iozone and try bigger test set (gigabytes) or use -I to bypass page cache.
here is the results when i am using the -I option
random random bkwd record stride
KB reclen write rewrite read reread read write read rewrite read fwrite frewrite fread freread
10240 1024 2356 2950 19693 20865 20833 2095 20111 1734 14375 2875 3566 386809 389443
write seq : 2,3 Mo/s
read seq: 19,2 Mo/s
write rand: 2 Mo/s
read rand: 20 Mo/s
read blk 20 Mo/s
why the read speed still so high ?
Within a bash script i need to get the total disk size and the currently used size of the complete disk.
I know i can get the total disk size without needed to be root with this command:
cat /sys/block/sda/size
This command will output the count of blocks on device SDA.
Multiply it with 512 and you'll get the amount of bytes on this device.
This is sufficient with the total disk size.
Now for the currently used space. I want to get this value without being root.
I can assume the device name is SDA.
Now there is this command: df
I thought i could use this command but it seems this command only outputs data of the currently mounted partitions.
Is there a way to get a total of space used on disk SDA without needing to be root and not all partitions needs to be mounted?
Let's assume the following example:
/dev/sda1 80GB Linux partition 20GB Used
/dev/sda2 80GB Linux Home partition 20GB Used
/dev/sda3 100GB Windows Parition. 30GB Used
Let's assume my SDA disk is partitioned like above. But while i'm on Linux my Windows partition (sda3) is not mounted.
The output of df will give me a grand total of 40 GB Used so it doesn't take sda3 in account.
Again the question:
Is there a way without root to get me a grand total of 70 GB used space?
I think stat command should help. You can get the get the partitions from /proc/partitions.
Sample stat command output:
$ stat -f /dev/sda1
File: "/dev/sda1"
ID: 0 Namelen: 255 Type: tmpfs
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 237009 Free: 236970 Available: 236970
Inodes: Total: 237009 Free: 236386
You can use df.
df -h --output='used' /home
Used
3.2G
If you combine this with some sed or awk you can have the value you seek
I'm running Ubuntu Trusty 14.04 on a new machine with 8GB of RAM, and it seems to be locking up periodically and nothing is in syslog file. I've installed Nagios and have been watching the graphs, and it looks like memory is going high from 7% to 72% in just a span of 10 mins. Only node process are running on server. In top I found all process are running very normal memory consumption. Even after stopping node process. Memory remains with same utilization.
free agrees, claiming I'm using more than 5.7G of memory:
free -h
total used free shared buffers cached
Mem: 7.8G 6.5G 1.3G 2.2M 233M 612M
-/+ buffers/cache: 5.7G 2.1G
Swap: 2.0G 0B 2.0G
This other formula for totaling the memory roughly agrees:
# ps -e -orss=,args= | sort -b -k1,1n | awk '{total = total + $1}END{print total}'
503612
If the processes only total 500 MiB, where's the rest of the memory going?
I've got solution on this... so just wanna to update the same...
echo 2 > /proc/sys/vm/drop_caches
This resolved my issue. So I have added the same in my cron for every 5 mins on each of ubuntu server
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
Please do not waste anymore of your time on this question...I ended up deleting the whole VM and creating another. The time it took me to do this is less than the time it would take to fix the issue. I have couple of SSDs in RAID mode.
Thank you for all those who tried to troubleshoot the issue!
I am having this problem with ubnuntu not showing active swap spaces when I run the command cat /proc/swaps. Here is a list of commands I ran. I even added a new swap space (file: /swapfile1) just to make sure that at least one swap space, but still I get nothing.
hebbo#ubuntu-12-lts:~$ sudo fdisk -l
[sudo] password for hebbo:
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders, total 52428800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e3a7a
Device Boot Start End Blocks Id System
/dev/sda1 * 46569472 52426751 2928640 82 Linux swap / Solaris
/dev/sda2 2046 46567423 23282689 5 Extended
/dev/sda5 2048 46567423 23282688 83 Linux
Partition table entries are not in disk order
hebbo#ubuntu-12-lts:~$ sudo su
root#ubuntu-12-lts:/home/hebbo# cat /proc/swaps
Filename Type Size Used Priority
root#ubuntu-12-lts:/home/hebbo# dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
524288+0 records in
524288+0 records out
536870912 bytes (537 MB) copied, 1.18755 s, 452 MB/s
root#ubuntu-12-lts:/home/hebbo# mkswap /swapfile1
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=cb846612-5f27-428f-9f83-bbe24b410a78
root#ubuntu-12-lts:/home/hebbo# chown root:root /swapfile1
root#ubuntu-12-lts:/home/hebbo# chmod 0600 /swapfile1
root#ubuntu-12-lts:/home/hebbo# swapon /swapfile1
root#ubuntu-12-lts:/home/hebbo# cat /proc/swaps
Filename Type Size Used Priority
root#ubuntu-12-lts:/home/hebbo#
Any idea how to fix this?
This is ubuntu 12.04 LTS running kernel 3.9.0 in a vmware VM.
Thanks in advance!
To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using a text editor such as vi:
# vi /etc/fstab
Add the following line:
/swapfile1 swap swap defaults 0 0
Save and close the file. Next time Linux comes up after reboot, it enables the new swap file for you automatically.
Have a look here for more info.
I just tried it and it works on my box.
Linux fileserver 3.8.0-32-generic #47~precise1-Ubuntu SMP Wed Oct 2 16:19:35 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
ortang#fileserver:~$ cat /proc/swaps
Filename Type Size Used Priority
/dev/dm-2 partition 4194300 0 -1
ortang#fileserver:~$ sudo su
root#fileserver:/home/ortang# dd if=/dev/zero of=/swapfile bs=1M count=512
512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 0.695721 s, 772 MB/s
root#fileserver:/home/ortang# chmod 600 /swapfile
root#fileserver:/home/ortang# mkswap /swapfile
Setting up swapspace version 1, size = 524284 KiB
no label, UUID=63cdcf3d-ba03-42ce-b598-15b6aa3ca67d
root#fileserver:/home/ortang# swapon /swapfile
root#fileserver:/home/ortang# cat /proc/swaps
Filename Type Size Used Priority
/dev/dm-2 partition 4194300 0 -1
/swapfile file 524284 0 -2
One thing i can imagine why it is working on my box, is that i already have a working swap partition, and it seems you don't.
It could also be caused by the kernel you use, 3.9.0 is not the regular 12.04.3 LTS kernel? Have you built the kernel yourself?
Whats the output of
grep CONFIG_SWAP /boot/config-`uname -r`
or
zcat /proc/config.gz | grep CONFIG_SWAP
is swap enabled in your kernel?
I ended up deleting the whole VM and creating another. The time it took me to do this is less than the time it would take to fix the issue. I have couple of SSDs in RAID mode. And I already had all the downloads on the same host machine. All in all ~7 minutes.
Thanks for all those who helped troubleshoot the issue.
On the command line this can be found out using the 'free' utility and 'cat /proc/meminfo'.
What would be the different ways to find out the physical RAM size in Linux programatically from a :
Userspace Application
Kernel Module
What API calls are available ?
#include <unistd.h>
long long physical_mem_bytes = (long long) sysconf (_SC_PHYS_PAGES) * sysconf (_SC_PAGESIZE);
Other than the command line ulimit, I don't know of a way of finding maximum memory for an individual process.
Programmatically, Linux won't tell you the actual physical size. Instead you should read this info from SMBIOS with, e.g.,
sudo dmidecode -t memory | fgrep -ie 'size:'
This will give you results like the following (from a box with 4 RAM banks, only 2 installed):
Maximum Memory Module Size: 16384 MB
Maximum Total Memory Size: 65536 MB
Installed Size: 2048 MB (Single-bank Connection)
Enabled Size: 2048 MB (Single-bank Connection)
Installed Size: Not Installed
Enabled Size: Not Installed
Installed Size: 2048 MB (Single-bank Connection)
Enabled Size: 2048 MB (Single-bank Connection)
Installed Size: Not Installed
Enabled Size: Not Installed
Size: 2048 MB
Size: No Module Installed
Size: 2048 MB
Size: No Module Installed
Add the reported sizes (or Enabled Sizes, but some BIOSes empirically don't report that) to get (in this case) 4096 MB. (Extra points for code that automates the parsing and arithmetic, but you can probably do that in your head nearly as reliably.)
To check your computation, run
fgrep -e 'MemTotal:' /proc/meminfo
The value reported by /proc/meminfo should not be more than the value you compute from dmidecode. In this case, empirically I get
MemTotal: 3988616 kB
cat /proc/meminfo
specifically from memory, I got this result from what Jared said
sudo dmidecode -t memory
there you can read the specs for each individual memory slot, so you will read something like 2048MB, in my case I have 2 of these being 4gb, despite my non PAE kernel only shows about 3.3gb and all other applications wont say the real physical memory, only dmidecode, thx!