Steps to reduce ArangoDB’s resource footprint
This is an update of the 2016 blog post How to put ArangoDB to Spartan-Mode.
A lot of things have changed in the last years. We moved our API implementation from JavaScript to C++. ArangoDB now has a new (default) storage engine, namely RocksDB instead of MMFiles. RocksDB is a great storage engine. However, it also trades memory for speed. If you start with the default configuration you might end up with using much more memory for ArangoDB than expected. Read more
Using The Linux Kernel and Cgroups to Simulate Starvation
When using a database like ArangoDB it is also important to explore how it behaves once it reaches system bottlenecks, or which KPIs (Key Performance Indicators) it can achieve in your benchmarks under certain limitations. One can achieve this by torturing the system by effectively saturating the resources using random processes.
This however will drown your system effectively - it may hinder you from capturing statistics, do debugging, and all other sorts of things you're used to from a normally running system. The more clever way is to tell your system to limit the available resources for processes belonging to a certain cgroup.
So we will put an ArangoDB server process (arangod) into a cgroup, the rest of your system won't be in.
Cgroups - What’s That?
Definition from Wikipedia:
cgroups (abbreviated from control groups) is a Linux kernel feature that limits, accounts for, and isolates the resource usage (CPU, memory, disk I/O, network, etc.) of a collection of processes.
Cgroups were introduced in 2006 and their first real usage example was that you were able to compile a Linux kernel with many parallel compilation processes without sacrificing the snappiness of the user interface – continue browsing, emailing etc. while your sysem compiles with all available resources.
Cgroups are available wherever you run a recent Linux kernel, including Docker Machine on Mac and Windows if you have root access to the host VM.
I/O Saturation
A basic resource you can run out of is disk I/O. The available bandwidth to your storage can be defined by several bottlenecks:
- the bus your storage is connected to - SATA, FC-AL, or even a VM where the hypervisor controls your available bandwidth
- the physical medium, be it spinning disk, SSD, or be it abstracted away from you by a VM
In a cooperative cloud environment you may find completely different behavior compared to bare metal infrastructure which is not virtualized or shared. The available bandwidth is shared between you and other users of this cloud. For example, AWS has a system of Burst Credits where you are allowed to have a certain amount of high speed I/O operations. However, once these credits dry up, your system comes to a grinding hold.
I/O Throttling via Cgroups
Since it may be hard to reach the physical limitations of the SUT, and – as we already discussed – other odd behavior may occur when loading the machine hard to its limits, simply lowering the limit for the processes in question is a good thing.
To access these cgroups you most likely need to have root access to your system. Either login as root for the following commands, or use sudo.
Linux cgroups may limit I/O bandwidth per physical device in total (not partitions), and then split that further for individual processes. So the easiest way ahead is to add a second storage device to be used for the ArangoDB database files.
At first you need to configure the bandwidth of the "physical" device; search its major and minor node ID by listing its device file:
ls -l /dev/sdc
brw-rw---- 1 root disk 8, 32 Apr 18 11:16 /dev/sdc
(We picked the third disk here; your names may be different. Check the output of mount to find out.)
We now mount a partition from sdc so we can access it with arangod:
/dev/sdc1 on /limitedio type ext4 (rw,relatime)
Now we alter the /etc/arangodb3/arangod.conf so it will create its database directory on this disk:
[database]
directory = /limitedio/db/
Here we pick the major number (8) and minor number (32) from the physical device file:
echo "8:32 1073741824" > /sys/fs/cgroup/blkio/blkio.throttle.write_bps_device
echo "8:32 1073741824" > /sys/fs/cgroup/blkio/blkio.throttle.read_bps_device
This permits a full gigabyte per second for the complete device.
We now can sub-license I/O quota for sdc into a CGroup we name limit1M which will get 1 MB/s:
mkdir -p /sys/fs/cgroup/blkio/limit1M/
echo "8:32 1048576" > /sys/fs/cgroup/blkio/limit1M/blkio.throttle.write_bps_device
echo "8:32 1048576" > /sys/fs/cgroup/blkio/limit1M/blkio.throttle.read_bps_device
We want to jail one arangod process into the limit1M cgroup, we inspect its welcome message for its PID:
2019-01-10T18:00:00Z [13716] INFO ArangoDB (version 3.4.2 [linux]) is ready for business. Have fun!
We add this process with the PID 13716 to the cgroup limit1M by invoking:
echo 13716 > /sys/fs/cgroup/blkio/limit1M/tasks
Now this arangod process will be permitted to read and write with 1 MB/s to any partition on sdc. You may want to compare the throughput you get using i.e. arangobench or arangoimport.
Real numbers
Depending on pricing and scaling cloud providers give you varying limits in throughput. It appears the worst case is Google at 3 MB/s (as of this posting).
- https://cloud.google.com/compute/docs/disks/performance
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html
So you may use your notebook with a high-end M2-SSD, and get an estimate whether certain cloud instances may handle the load of your application.
Using the ArangoDB Swagger.io Interactive API Documentation
ArangoDB bundles its regular API Documentation also in Swagger.IO API description format. You can browse and explore it interactively via the ArangoDB Webinterface.
Read more
Performance analysis with pyArango: Part III Measuring possible capacity with usage Scenarios
ArangoDB | PyArango Performance Analysis – Transaction Inspection
Following the previous blog post on performance analysis with pyArango, where we had a look at graphing using statsd for simple queries, we will now dig deeper into inspecting transactions. At first, we split the initialization code and the test code.
Initialisation code
We load the collection with simple documents. We create an index on one of the two attributes: Read more
Performance analysis using pyArango Part I
This is Part I of Performance analysis using pyArango blog series. Please refer here for: Part II (cluster) and Part III (measuring system capacity).
Usually, your application will persist of a set of queries on ArangoDB for one scenario (i.e. displaying your user’s account information etc.) When you want to make your application scale, you’d fire requests on it, and see how it behaves. Depending on internal processes execution times of these scenarios vary a bit.
We will take intervals of 10 seconds, and graph the values we will get there:
- average – all times measured during the interval, divided by the count.
- minimum – fastest requests
- maximum – slowest requests
- the time “most” aka 95% of your users may expect an answer within – this is called 95% percentile
ArangoDB Snapcraft Packaging: Simplified Deployment
ArangoDB Packaging
With ArangoDB 3.0 we reworked the build process to be based completely on cmake. The packaging was partly done using cpack (Windows, Mac), for the rest regular packaging scripts on the SuSE OBS were used. With ArangoDB 3.1 we reworked all packaging to be included in the ArangoDB Source code and use CPack. Users can now easily use that to build their own Packages from the source, as we do with Jenkins. Community member Artur Janke (@servusoft) contributed the new ubuntu snap packaging assisted by Michael Hall (@mhall119). Big thanks for that!
Download packages for Snap Ubuntu Core16.04 Read more
Public Key Infrastructure: Setup Guide for Debian & Ubuntu
We want to have a full chain of trust for our debian packages. Therefore the Suse Open Build Service (OBS) service signs them. We publish the key alongside the repository.
However, one can do better and do the validation right on apt-get install arangodb. Here’s how: (more…)
MERII Hummingbird A80 Optimus Cluster: ArangoDB Deployment
For running ArangoDB in clusters doing performance tests we wanted to have a non virtualized set of descent hardware with fast ethernet connection, enough RAM (since thats what Arango needs) and multicore CPU. Since you need a bunch of them, cheap ARM devel boards come to mind. The original Raspberry PI (we have those) is out of the game due to V8 is not supporting it anymore. The now available PI 2 doesn’t cut it, since its ethernet NIC is connected via USB (as on the original PI). The Odroid series only have one of both: Fast ethernet or enough RAM. The Cubieboard 4 wasn’t available yet, but its Allwinner A80 SOC seemed a good choice. Then we met the Merii Optimus board, which seems to be almost the same as the PCDuino (now renamed to Arches) with the A80. While we got a bunch of them for a descent price over at Pollin, the upstream support wasn’t that good.
However, with some help of the SunXi-Linux Project we started flashing OS images to replace the preloaded Android image with the Merii Linux image. Since the userland of the Merii image is pretty sparse, we wanted something more useable. There is already a how-to on running Ubuntu which requires running a Windows host. We prefer a Linux host and want to run a Debian. Since the new Pi2 is also able to run regular Debian with ArmV7, we pick the root fs from sjoerd.
String Comparison Performance: ArangoDB Query Optimization
We’ve been using Callgrind with its powerful frontend KCachegrind for quiet some time to analyse where the hot spots can be found inside of ArangoDB. One thing always accounting for a huge chunk of the resource usage was string comparison. Yes, string comparison isn’t as cheap as one may think, but its been even a bit more than one would expect. And since much of the business of a database is string comparison, its used a lot.
ArangoDB and V8 use the ICU Library for these purposes (with no alternatives on the market) – so basically we heavily rely on the performance of the ICU library. However, one line in the ICU change-log – ‘Performance: string comparisons significantly faster’ – made us listen up.
So it was a crystal clear objective to take advantage of these performance improvements. As we use the ICU bundled with V8, we had to make sure it would work smooth for it first ;-). After enrolling the upgrade, we wanted to know whether everything was working fine with valgrind etc, and get some figures how much the actual improvement is.
(more…)
Get the latest tutorials,
blog posts and news:
Thanks for subscribing! Please check your email for further instructions.
Skip to content