Please be allow me to ask a question here relevant to Redis 5.0.5 (00000000/0) 64 bit.
I have an production on EC2 AWS, it's running LEMP Stack (PHP 7.3.9 (cli) (built: Aug 27 2019 22:52:39) ( NTS )/nginx version: nginx/1.12.2/Server version: 10.4.8-MariaDB-log MariaDB Server)
Currently, we have recorded sometime web server down in 1-2 minutes. At the time, I have looked at the logs file (Nginx/Php/Redis). None one of them points out to me what's the problem happening? Then I was looking at the Redis logs, and I have a little doubt about this. Please can you look at it as the logs below?
Dear Greg Andrews,
Thank you for sending me the information as well explained more in detail in this case.
Please allow me to ask you more a question. As I mentioned previously in this message, I would like to provide you with more information about the environment I'm running on EC2 Production.
[1] Linuy distro (CentOS Linux release 7.6.1810 (Core))
[2] I have installed Redis from a package provided as part of the distro with Rpm.
[3] I checked CPU/RAM/usage around that time. It's low
[4] As far as I know in the blogs you give me before.
Tip Redis is single-threaded. Every command may block other commands. Keep this in mind if you start thinking about problems or use cases. This seems obvious but is mostly overlooked and the root cause of many issues.
Is there a connection that will be killed or Redis will keep blocking the access that will cause our customers can't access our web at that time?
[5] it's the files /etc/php-fpm.d/www.conf.
php_value[session.save_handler] = redis
php_value[session.save_path] = tcp://127.0.0.1:6379
I want to mention it because if we have a Redis, the website is still alive. Is it can't stop or deny access from outside?
Only a hypothesis can happen, it's Redis blocking access, PHP-FPM is waiting for the Redis release session. It denies a new connection.
[6] I checked the Redis logs and discovered that Redis was saving data to disk every few minutes:
24808:C 12 Oct 2020 04:07:15.620 * DB saved on disk
24808:C 12 Oct 2020 04:07:15.622 * RDB: 8 MB of memory used by copy-on-write
5221:M 12 Oct 2020 04:07:15.701 * Background saving terminated with success
5221:M 12 Oct 2020 04:12:16.006 * 10 changes in 300 seconds. Saving...
5221:M 12 Oct 2020 04:12:16.008 * Background saving started by pid 30330
30330:C 12 Oct 2020 04:12:19.526 * DB saved on disk
30330:C 12 Oct 2020 04:12:19.527 * RDB: 8 MB of memory used by copy-on-write
5221:M 12 Oct 2020 04:12:19.610 * Background saving terminated with success
5221:M 12 Oct 2020 04:17:20.085 * 10 changes in 300 seconds. Saving...
5221:M 12 Oct 2020 04:17:20.087 * Background saving started by pid 3544
3544:C 12 Oct 2020 04:17:23.616 * DB saved on disk
3544:C 12 Oct 2020 04:17:23.618 * RDB: 8 MB of memory used by copy-on-write
5221:M 12 Oct 2020 04:17:23.692 * Background saving terminated with success
[7] php-fpm log
[11-Oct-2020 16:00:09] WARNING: [pool www] child 21023, script '/var/www/index.php' (request: "GET /index.php") executing too slow (3.967548 sec), logging
[11-Oct-2020 16:00:09] NOTICE: child 21023 stopped for tracing
[11-Oct-2020 16:00:09] NOTICE: about to trace 21023
[11-Oct-2020 16:00:09] NOTICE: finished trace of 21023
[11-Oct-2020 16:00:13] WARNING: [pool www] child 12154, script '/var/www/index.php' (request: "POST /index.php") executing too slow (3.552117 sec), logging
[8] As far I know from the blog "One connection per request" I quote it again.
We accepted the challenge with the ever growing amount of traffic in the following months and further optimized our application and stack in several ways. Some of our goals were tackling the consumption of memory per request, optimizing our database queries (slow query log), tuning our caching layers and adding more hardware (web servers) to our datacenters. Especially the last change, adding more web servers to our stack, created yet another challenge.
As mentioned earlier, we were dealing with stateless applications. Without the usage of php-fpm and persistent connections this means:
An HTTP request comes in
The application creates connections to various services
Operations are executed, queries are run, requests are made, etc.
The application closes connections created in 2.
The reponse is delivered to the client
This worked great so far and this is the way many applications work. But if you scale the number of servers that can accept incoming requests, your traffic grows and you don`t pay special attention to your 3rd party components this can go wrong. Very wrong.
Depending on the request, the application creates third party connections, executes one or two commands and disconnects again. 50% up to 75% of the commands we execute are used for connection handling. Remember Redis is single threaded. If you have a lot of clients that try to connect to your Redis instance continuously, you will keep your instance busy with connection handling instead of executing the commands you run your business logic on. This may lead to a slowdown/blocking of your Redis instance. The (simplified) image above visualizes the problem. Every arrow represents one HTTP client request.
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/da186d26-d40b-4056-8d2e-509d380078c3n%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/b5e83167-7bfd-4c6a-bc3a-832ac32a2b0dn%40googlegroups.com.
Disclaimer
The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/CAMzF2K3Ni%2B7VWiFtwjeGVSH9U-hXnJWa0Cizx-_PY2aAJo5QKw%40mail.gmail.com.