How do I reduce my server response time (apache2)

Hi, so I am currently using the Linode 2GB plan to host a simple eCommerce site under the domain name www.eblossom.lk

But for some unknown reason, my site has got really slow, and after using google page insights I have realised that my site is really slow and my largest contentful paint takes over 22 seconds to load, which is too long. Also at this very moment, only one or 2 users will be using it, in which the resources the server has is plenty to deal with the users.

I am using a platform called Django to host my application and using Ubuntu 20.10 with apache2.

I googled ways to help improve my server response time and tried articles such as…

  1. https://www.linode.com/docs/guides/tuning-your-apache-server/
  2. https://rigor.com/blog/best-ways-reduce-server-response-times/

I had also come across some article that told me to alter my .htaccess in apache2 and enable my mod_mem_cache, but I don't know where I can find the related apache files and what do I exactly need to type.

I am fairly new to apache and have aced the basics…just need some advice on how to reduce my server response time. If it is something regarding apache2 configuration files, it would be greatly appreciated if you could be a bit more specific on what file it is and its location.

Any help would be greatly appreciated.

Thanks!

8 Replies

I did a quick look at the internals of the site and I don't see this as a Linode server issue, but rather a website issue. It looks like you download FontAwesome three times and Bootstrap twice. I can't tell if your pictures are optimized or not. Still, even with the above, the site should NOT be as slow as it is.

I don't know what this is, but it does not resolve to anything:

<script language="Javascript" src="https://www.bw2021.lk/stats.php?page=2021"/></script> 

I don't know why you chose Django as your platform… it would not be my choice as I don't know how much overhead and 'bloat' Django has.

What Linode datacenter are you using? What DNS nameservers are you using?

Sorry I'm not more help but Django is not a platform I know much about. Maybe there is something here that will help you:
https://docs.djangoproject.com/en/3.2/topics/performance/

or maybe:

https://mattsegal.dev/is-django-too-slow.html

Let us know what you find out.

I would run a website test to get a breakdown of what and where things are running slow at. It could as Acanton77 said that you could have images that are too large or other issues.

This site is a good resource for that. https://tools.pingdom.com/

Ok so checking it out a bit, I tried removing off the script tag @acanton77 mentioned…

And that script tag was actually given to me by a website competition authority where they told me to add the link in order to access the site…

Seems like removing that off has increased the speed of my website by 50%, which is really great.

So thanks a lot for your help. It's much appreciated.!

However another small thing… even after removing off that script tag, my website speed has improved dramatically.

However, according to google page insights, I still get that my initial server response time is around 4 seconds as shown in this screenshot.

Is there anything I could do to improve this?

Thanks!

I don't know if this is possible given your infrastructure, but you might try one of the multi-threaded apache2(8) MPMs -- mpm-event or mpm-worker -- instead of mpm-prefork.

-- sw

For testing take out this image… I think it is hanging on obtaining it.

vote4us.png

When I ran I see this is still in:

<script language="Javascript" src="https://www.bw2021.lk/stats.php?page=2021"></script> <!-- From bestweb.lk -->

Somewhere you have code in for a favicon but I see a not found message for it:

Failed to load resource: the server responded with a status of 404 (Not Found)
https://www.bw2021.lk/favicon.ico

@stevewi those words…. so complicated lol. What do they exactly do and how can I do that?

So… apache2(8) for Unix/Linux is shipped with three multi-processing modules called mpm-prefork, mpm-worker, and mpm-event. Each are designed to handle requests in a different way. mpm-prefork is the oldest and most portable and uses continually-spawning/-dying processes. mpm-worker and mpm-event are newer and use threads in different ways. You can read about all of them here: https://httpd.apache.org/docs/2.4/mpm.html

Generally, mpm-worker and mpm-event are more efficient and less-resource-hungry than mpm-prefork on modern multi-processor systems. However, that means anything internal to them must be thread-safe. In the past, that has usually only meant the embedded PHP module can only run using the mpm-prefork model.

Like @acanton77, I don't know anything about Django (or python3(1)) and how it communicates with apache2(8). To my knowledge, there's no "embedded python" module that comes with apache2(8). However, that does not mean one does not exist. If such a beast exists, it must be thread-safe in order for you to use one of the multithreaded MPMs. You should check that…

If there is some external entity that handles python3(1) on apache2(8)'s behalf, the two must communicate somehow. You need examine that communication channel as well to make sure it's the most efficient and low-overhead (and secure) that it can be. Generally, you'll want to use a local-/unix-domain socket instead of an internet-domain socket because of lower overhead. See: https://serverfault.com/questions/124517/what-is-the-difference-between-unix-sockets-and-tcp-ip-sockets

Given that you think all this is "complicated", I'm afraid that you have a fairly steep learning curve ahead of you in order to solve your problem.

-- sw

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct