I have a small, low-traffic Django/Wagtail-based site that I'm trying to host with PythonAnywhere on a Hacker account. I've been testing for several months now and finally moved the production site over using MySQL as the database backend. I noticed during testing that server response was rather slow, but I thought once I got the production site set up with CloudFlare as a caching proxy, it wouldn't be an issue. The site is very low-traffic and doesn't need blazing speed.
However, I'm finding that when requests need to go through to the Django server on PythonAnywhere, response times are (what I would consider) very slow: in the range of 7-10 seconds, typically. When either the CloudFlare or Django/Wagtail caches serve the content, response times are fine (~ 0.5s). I've spent a while now tweaking both the CloudFlare and Django cache settings, as well as running a cron job every hour to crawl the site and try to keep the caches fresh. This works to some extent, but inevitably (it seems) some of the time the caches will miss and it will take 10 seconds for a page to load. I have confirmed that the slowdown only occurs on cache misses. The site is small, built around mostly vanilla Wagtail, and I've used Django Debug Toolbar to check that it isn't being slowed down by too many database calls. I have also ruled out network transfer speed as an issue using various debugging tools.
For comparison, today I loaded a fresh copy of the site on an EC2 t3a.small (2 vCPUs, 2 GB RAM) instance, running with identical production settings to the PythonAnywhere install, and it is quite snappy (<1s response for most pages, ~1.5s response for the only page with a lot of dynamic, database-driven content).
I have done quite a bit of reading of this forum and others, and seen similar questions, but haven't found any solution that works for me. Is this just the expected performance on PythonAnywhere given the shared hardware in use? Is there anything I can try to improve response times to an acceptable level, other than switching hosts? I did try increasing the number of workers in my account to four, but that doesn't seem to help and I reverted it.
Thanks in advance for any help, Jeremy