Limitations in fastdb shared memory mode

Source: Internet
Author: User

Fast dB has been used in recent projects. To improve access efficiency, fast dB adopts the diskless mode for compilation.
The maximum size of shared memory is limited by system parameters,
The following data is the default value in Linux im_monitor 2.6.9-42. elsmp:
CAT/proc/sys/kernel/shmmax
33554432
The default size is 32 MB;

In fastdbCode32 m is also used as the capacity limit. Once the capacity exceeds the threshold, expansion will not be performed; the process will exit;
The specific code line is in the INC/database. h file.
# Ifdef diskless_configuration
// In diskless confiuration database can not be reallocated
Const size_t dbdefaultinitdatabasesize = 32*1024*1024;
# Else
Const size_t dbdefaultinitdatabasesize = 1024*1024;
# Endif

To support fastdb to work in larger shared memory, you need to make two changes:
1. Modify system parameters
Modify/etc/sysctl. cfg and add the following content:
Kernel. shmmni = 4096
Kernel. Shmall = 2097152
Kernel. shmmax = 1073741824
Run sysctl-P;
Or echo 1073741824>/proc/sys/kernel/shmmax. Be sure to add it to the startup script;

2. Modify fastdbSource code
Const size_t dbdefaultinitdatabasesize = 32*1024*1024; change to an appropriate value, for example, 32-> 1024

In view of the size limit of shared memory and the inability to dynamically scale up: when the capacity limit is exceeded, the process cannot be reassigned and exited directly. For large-capacity systems, fastdb data exceeds 2 GB, or the Total virtual memory usage may be close to 3 GB. Therefore, we do not recommend using the shared memory fastdb in a 32-bit operating system. You can use the File mode instead, it is also implemented through MMAP. Writing Io is basically equivalent to memory efficiency and can be expanded based on pre-allocation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.