Score:0

How to remove apcu and memcached from centos?

id flag

I've always installed apcu and memcached on my server, but I'm not sure how useful they are. Mostly 2-3 pages per visit are visited on my sites. And I'm not even sure if having them is a good thing or a bad thing, whether it's talking about SEO or consuming or saving server resources.

I would like to try to remove them and see what happens... But I find tons of guides on how to install them and none on how to remove them... so I have a few questions:

  • is it possible to remove apcu and memcached?
  • Most importantly is it possible to do it safely without destroying the server?
  • and perhaps more importantly, is it such a stupid idea to remove them?

Additional information:

enter image description here

The server works fine, it has some spikes when a big cronjob starts (or when someone tries to attack it, but fail2ban takes care of it) but for the rest of the time it still has a lot of resources available. But slowly the memory fills up more and more, and everything is getting closer and closer to red, perhaps because of apcu or memcached?

djdomi avatar
za flag
what are you trying to fix?? i think you have an [X-And-Y-Problem](https://faq-database.de/doku.php?id=en:x-and-y-problem)
alebal avatar
id flag
??? What do you mean?
djdomi avatar
za flag
so you speculate that memcached that has an fixed memory limit can be an issue? Moreover php apcu is also limited by php memory limits afaik, so what is your original issue?
alebal avatar
id flag
Please can you re-read my orginal question?
djdomi avatar
za flag
i answered to your 3 questions but i still think there might be the question of why the server runs in such a Peak and that might be your x and y Problem
Score:0
za flag

The Short Answer:

  • is it possible to remove APCu and Memcached?

    Yes

  • is it possible to do it safely without destroying the server?

    Yes

  • is it such a stupid idea to remove them?

    Well, it depends

The Longer one:

APCU is just a PHP module

  • How-to disable?
    • echo "apc.enabled=0" >> /etc/php/7.3/mods-available/apcu.ini 
      
      • When you're using PHP 7.3 (like in my case)

Memcached is an extra daemon

What's Memcached

Memcached is a flexible memory object caching daemon designed to alleviate database load in dynamic web applications by storing objects in memory.
It's based on libevent to scale to any size needed, and is specifically optimized to avoid swapping and always use non-blocking I/O.

It will only Consume the Memory as defined down below (in my case 512mb) You have multiple options, on how to use and even to remove it. Due to I use Debian, the following one is the usually one.

BUT Remind, you have to remove that also from your Application. Else it can either break or do wired things.

Debian
apt remove memcached

This does not remove the Configs, you may want to add --purge to that above command to remove it completely.

CentOS
yum remove <package>

In case you don't find the correct name, use

yum list installed |grep <name>
memcached.conf
# memcached default config file
# 2003 - Jay Bonci <[email protected]>
# This configuration file is read by the start-memcached script provided as
# part of the Debian GNU/Linux distribution.

# Run memcached as a daemon. This command is implied, and is not needed for 
the
# daemon to run. See the README.Debian that comes with this package for more
# information.
-d

# Log memcached's output to /var/log/memcached
logfile /var/log/memcached.log

# Be verbose
# -v

# Be even more verbose (print client commands as well)
# -vv

# Start with a cap of 64 megs of memory. It's reasonable, and the daemon 
default
# Note that the daemon will grow to this size, but does not start out 
holding this much
# memory
-m 64

# Default connection port is 11211
-p 11211

# Run the daemon as root. The start-memcached will default to running as 
root if no
# -u command is present in this config file
-u memcache

# Specify which IP address to listen on. The default is to listen on all IP 
addresses
# This parameter is one of the only security measures that memcached has, so 
make sure
# it's listening on a firewalled interface.
-l 127.0.0.1
-l [::1]
# Limit the number of simultaneous incoming connections. The daemon default 
is 1024
# -c 1024

# Lock down all paged memory. Consult with the README and homepage before 
you do this
# -k

# Return error when memory is exhausted (rather than removing items)
# -M

# Maximize core file limit
# -r

Conclusion

Let's go again on your Point

  • is this a bad idea to remove them?
    It depends on the use case due to the fact it should improve the Performance. Even on my Smallest LXC Container (1CPU/128MB Ram), it is Possible, to run php-apc and memcached without problems. And Moreover, both “Caches” are limited by a Configuration item into the Maximum usage of RAM.

As Already stated, I still think that there might be a X-and-Y-Problem

Since you did not provide additional information at the moment, but 3 Questions. So far, I answered this at the moment of the current state.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.