Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of redis connection timeout

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how to solve the problem of redis connection timeout. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Problem description:

The redis connection timed out, then navigated to the redis profile directory to be deleted, then tried to restart redis and found that the connection was broken and did not start successfully.

Error report:

View the output log of redis. The error shown in the following figure appears:

Add vm.overcommit_memory = 1 to the / etc/sysctl.conf file as prompted

Modify its large transparent page and restart the timeout of the adjusted redis from 300 to 500 normally

Echo never > / sys/kernel/mm/transparent_hugepage/enabled

About vm.overcommit_memory

It is the optional value of memory allocation policy: 0, 1, 2. 0, which means that the kernel will check whether there is enough memory available for the application process; if there is enough memory available, the memory request is allowed; otherwise, the memory request fails and the error is returned to the application process. 1, which means that the kernel allows all physical memory to be allocated, regardless of the current memory state. 2, indicating that the kernel allows more than the sum of all physical memory and swap space to be allocated

About Overcommit and OOM

Linux replies "yes" to most requests for memory so that it can run more and larger programs. Because memory will not be used immediately after applying for memory. This technique is called Overcommit. OOM killer (OOM=out-of-memory) occurs when linux finds that it is out of memory. It chooses to kill some processes (user-mode processes, not kernel threads) to free memory. Which processes does linux choose to kill when oom-killer occurs? The function for selecting a process is the oom_badness function (in mm/oom_kill.c), which calculates the number of points for each process (0,1000). The higher the points, the more likely the process is to be killed. The number of points per process is related to oom_score_adj, and oom_score_adj can be set (- 1000 lowest, 1000 highest).

About / sys/kernel/mm/transparent_hugepage/enabled

Transparent big page introduces some official introduction materials of Transparent Huge Pages: Transparent Huge Pages (THP) are enabled by default in RHEL 6 for all applications. The kernel attempts to allocate hugepages whenever possible and any Linux process will receive 2MB pages if the mmap region is 2MB naturally aligned. The main kernel address space itself is mapped with hugepages, reducing TLB pressure from kernel code. For general information on Hugepages, see: What are Huge Pages and what are the advantages of using them?The kernel will always attempt to satisfy a memory allocation using hugepages. If no hugepages are available (due to non availability of physically continuous memory for example) the kernel will fall back to the regular 4KB pages. THP are also swappable (unlike hugetlbfs). This is achieved by breaking the hugepage to smaller 4KB pages, which are then swapped out normally.But to use hugepages effectively, the kernel must find physically continuous areas of memory big enough to satisfy the request, and also properly aligned. For this, a khugepaged kernel thread has been added. This thread will occasionally attempt to substitute smaller pages being used currently with a hugepage allocation, thus maximizing THP usage.In userland, no modifications to the applications are necessary (hence transparent). But there are ways to optimize its use. For applications that want to use hugepages, use of posix_memalign () can also help ensure that large allocations are aligned to hugepage (2MB) boundaries.Also, THP is only enabled for anonymous memory regions. There are plans to add support for tmpfs and page cache. THP tunables are found in the / sys tree under / sys/kernel/mm/redhat_transparent_hugepage.

Check if transparent large pages are enabled

When cat / sys/kernel/mm/transparent_hugepage/ enabled [always] madvise never uses the command to view, if the output is [always], the transparent large page is enabled. [never] means transparent large pages are disabled, [madvise] means (using THP only in VMA of MADV_HUGEPAGE flag how HugePages_Total returns 0, also means that standard large pages are disabled (note the difference between traditional / standard large pages and transparent large pages) transparent large pages (THP) management and standard / traditional large pages (HP) management are new features released by the operating system to reduce the resources consumed by page table conversion Although ORACLE recommends using the large page mechanism to improve database performance, ORACLE also recommends turning off transparent large page management. The difference between the two lies in the allocation mechanism of large pages, standard large page management is the way of pre-allocation, while transparent large page management is the way of dynamic allocation. [root@appnode001 ~] # grep-I HugePages_Total / proc/meminfo HugePages_Total: 0cat / proc/sys/vm/nr_hugepages returns 0 also means that traditional large pages are disabled (traditional large pages and transparent large pages). [root@appnode001] # cat / proc/sys/vm/nr_hugepages0 Thank you for reading! This is the end of this article on "how to solve the problem of redis connection timeout". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report