1

Due to budget constraints, I'm using the smallest droplet that DigitalOcean provides, which is running a small (4 or 5 users) legacy php application for a client until I can rewrite it for them. I have just installed redis in order to try to boost performance for a few of the more expensive database queries. I have looked at the questions listed at the bottom, and believe that I still need to ask this question. I do not want to do "capacity planning" at this stage. I just want to come up with a so-called "<sane value>" for maxmemory per the accepted answer of the redis question cited below, based on the typical demands of apache httpd 2.2.15, php 5.3.3, and mysql 5.1.73 running on CentOS 6.9 (like I said, legacy).

The output from free -h when no one is using the app is

             total       used       free     shared    buffers     cached
Mem:          1.0G       809M       197M       368K       179M       484M
-/+ buffers/cache:       145M       860M
Swap:           0B         0B         0B

I am concerned by the fact that /etc/php.ini has memory_limit = 256M and I am alarmed by the output of config get maxmemory in redis-cli, as it appears that the default setting doesn't bother at all to find out what's actually available on the system.

127.0.0.1:6379> config get maxmemory
1) "maxmemory"
2) "3221225472"

My gut tells me that if I naively set memory_limit and maxmemory both to 98M, I am going to experience grief if the app is running at capacity and suddenly the system decides to fire up some random housekeeping processes, or I need to jump into vi to fix something on the fly (not that I'd ever do that on a production machine). Hmm, and I just now realized I haven't even taken mysql's working memory into consideration.... Note that #551727 discusses tuning strategies, but doesn't actually answer the question concerning how much free memory should be maintained.

Questions researched:

Can you help me with my capacity planning?

How much free memory should I have on my webserver?

https://stackoverflow.com/questions/33115325/how-to-set-redis-max-memory

1
  • Additional info request. # cores, any SSD or NVME devices on MySQL Host server? Post on pastebin.com and share the links. From your SSH login root, Text results of: B) SHOW GLOBAL STATUS; after minimum 24 hours UPTIME C) SHOW GLOBAL VARIABLES; D) SHOW FULL PROCESSLIST; E) complete MySQLTuner report AND Optional very helpful information, if available includes - htop OR top for most active apps, ulimit -a for a Linux/Unix list of limits, iostat -xm 5 3 for IOPS by device and core/cpu count, for server workload tuning analysis to provide suggestions. May 22, 2020 at 23:41

1 Answer 1

0

Capacity planning cannot be avoided. As an answer you linked to said, "it depends".

Maintain enough available memory (also known as cached as you won't have any unused left as free). "Enough" meaning memory pressure won't slow things horribly while its trying to reclaim. And worst case, the OOM killer is bad news.


And now for the many questions to make this a quantitative estimate. Consider starting a spreadsheet, there are a few...

How many seconds of response time will be acceptable performance? How fast are requests now, at the user agent perspective?

What does host memory look like under load? Record all of /proc/meminfo which has more specific subtotals.

Are the 5 users the maximum expected, and is that concurrent users? Maybe you can get by with 5 or fewer worker processes.

Is MySQL on this box? What its maximum configured memory consumption when all the parameters are added up? Most probably comes from innodb_buffer_pool_size and maybe max_connectionssort_buffer_size. Use for example https://www.mysqlcalculator.com/ and https://launchpad.net/mysql-tuning-primer

How is httpd configured? How many workers? Is php mod_php, or fpm ? What is the typical per httpd process RSS, such as from top?

Regarding "more expensive database queries". What does the slow query log look like? Can queries be made more efficient?

Regarding adding a caching tier. Do repeat queries happen that would benefit from such a cache? Would you need to write code to leverage a cache, or is it already in the application? Is your precious MB better spent on DB buffers? Even at minimum size, I would still budget a couple hundred MB to add Redis.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .