I am really new to server development. I have a server (Server version: Apache/2.4.41 (Ubuntu)) for Django and it's running on apache2. I want to use Memcache for a large queryset. I just wanna use the following Django future:

    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache',
        'LOCATION': '',

As I understand with the documentations I have to install Memcached, configure, and start at systemctl. As I mention before I have an apache2 server on systemctl. If I will install Memcached with sudo apt install memcached, is it going to be a problem?

I am really scaring to install something on the server because we have almost 20 projects running on apache2 and I don't want to ruin it. I try to use apache2 and nginx at the same time in the past and it causes big problems.

Which way should I follow to use memcached?. Do I have to buy a new server?

  • Apache2 and nginix are both http servers, so of course they cause big problems unless you isolate their ports.
    – RonJohn
    Jul 19, 2021 at 15:59

2 Answers 2


Yes, you can run memcached on the same server safely, if you have enough free memory available to store whatever data it will cache.

The purpose of memcached is to keep some data in memory so that it can be accessed more quickly than by loading it from disk repeatedly. That means that memory will be unavailable for other purposes while it is being used for caching your application data.

You should have some idea of how much memory will be needed. If you do not already know, you can run tests in your test environment. Because you mention a large queryset, you probably already know approximately how much memory this will need.

After you know approximately how much memory you need, you can decide if your server already has enough memory, or if you need to add more memory (or use another server).

  • I have 128gb of ram and I am using cache in 3 different project. The data will be about 30 gb. Curently I am just using 5 gb of ram. Jul 18, 2021 at 14:41

Can I use apache2 and memcache in same server?

the answer is: Yes you can run memcached on the same machine

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.