Moodle performance tuning and caching

Moodle slows under exam-day load for predictable reasons: PHP and database settings, cache and session stores, cron and ad hoc task capacity, and file serving. This page covers how to tune each, verify it with load tests, and decide what to hand to a partner.

On this page

Why Moodle performance tuning and caching needs a plan before exam periods

Moodle performance comes from several layers working together: PHP, the database, the cache stores, sessions, scheduled and ad hoc tasks, and file storage. A self-hosted site that runs well on an ordinary Tuesday can still stall during a timed quiz, a bulk enrolment run or a grade release, because those events hit different layers at once. Planning for an exam period means deciding how each layer is configured, who owns it and how you will prove it holds before students log in. Treating it as a single server setting usually leads to guesswork and repeated late-night changes.

The difficulty is that symptoms and causes often sit in different places. A quiz page that times out may look like a web server problem, but the real cost can be uncached database queries, a session store that serializes requests, or a cron backlog that keeps tasks waiting while grades are still being calculated. The reverse also happens: a slow database may be caused by a plugin that writes heavily on every page view. Your team should record which layer each symptom points to before changing anything, so that one fix does not hide another problem.

Version and platform requirements also limit your options. Each Moodle release names supported PHP and database versions, and the minimum versions change over time. For example, Moodle 5.1 requires 64-bit PHP 8.2 or later and PostgreSQL 15, MySQL 8.4, MariaDB 10.11 or SQL Server 2017 or later, and Moodle 5.3 raises those minimums. Confirm the exact requirements for your target release in the Moodle 5.1 release notes and the Moodle releases page before you choose settings, because a tuning change that depends on a newer engine version may not be available on your current stack.

Which Moodle components decide speed under load

Moodle's speed under load comes from several layers that interact: the PHP runtime, the database, the cache, sessions, background tasks and file storage. A slow point in one layer often shows up as a symptom in another, so tuning works best when each component is checked and measured on its own before a load test.

PHP runtime and opcache

PHP executes every page request, so its version, memory limits, execution limits and opcache configuration set the baseline for response time. Moodle 5.1 requires 64-bit PHP 8.2 or later, and Moodle 5.3 requires 64-bit PHP 8.3 or later, so the target release sets the floor. Check that opcache is enabled with enough memory for the codebase, and confirm the PHP-FPM worker count matches the CPU and memory of each web node.

Moodle 5.3 notes

Database engine and configuration

Almost every page view reads or writes the database, so engine version and configuration matter as much as query design. Supported engines depend on the release: PostgreSQL 15, MySQL 8.4, MariaDB 10.11 or SQL Server 2017 for 5.1, and PostgreSQL 17 or MariaDB 11.4 for 5.3. Review buffer pool or shared buffer sizing, connection limits, slow query logging and whether the database has its own server or shares a host with web nodes.

Moodle 5.1 notes

Moodle cache stores and definitions

Moodle caches configuration, course data and session-adjacent items through cache stores and cache definitions in the administration area. The choice of store determines whether caches are shared across web nodes or kept per node, and that choice must match your deployment. Confirm which store backs each application and session cache definition, check hit rates through the cache tools, and avoid leaving local file caches in place on a multi-node setup.

Session handling

Sessions decide whether a learner stays logged in across web nodes and how much storage each request consumes during peak logins. Where sessions are stored (database, Redis or Memcached, or files) affects latency and failover. Check session timeout settings against the exam or assessment window, and confirm that session storage is shared when more than one web node serves the same site. Test logins under concurrency, not just single-user page loads.

Cron and ad hoc task workers

Scheduled cron tasks and ad hoc tasks such as grade recalculation, backups, email and report generation run outside normal page requests, and a backlog here slows the whole site. Check that the system cron runs every minute as Moodle expects, watch the task log for long-running or failed jobs, and confirm how many adhoc task runners execute in parallel. Exam days often expose task queues that were invisible during normal use.

moodledata file storage

The moodledata directory holds uploaded files, course content and caches, and on a multi-node site it must be shared by every web and cron node. Storage latency, throughput and file locking all affect page load and upload time, particularly for large media or quiz attachments. Confirm the shared filesystem type with your infrastructure team, check free space and inode headroom, and include moodledata in backup and restore timing tests.

Choosing cache stores, session storage and task design

Moodle keeps application caches and user sessions in configured cache stores. On a single web node, the default file-based or database-backed stores are often enough, because there is only one process reading and writing them and no second node needs to see the same session. Keeping stores local adds no service to run, so there is less to patch, back up and monitor. Once several web nodes sit behind a load balancer, a session written on one node must be readable from another, so a shared store such as Redis or Memcached is the usual choice. That shared store becomes a dependency: if it fails or restarts, users can be logged out and caches rebuild under load. Confirm with Moodle's cache and session documentation for your release which store types are supported, how sessions are configured, and what happens to in-flight sessions when the store is restarted. Ask your platform team who will own its availability, monitoring and memory limits.

  • Local file or database stores: Fit a single node with modest concurrency. Nothing extra runs, but the stores cannot be shared across nodes.
  • Shared Redis or Memcached: Fits multiple web nodes. It adds a service with its own uptime, memory sizing and failure mode.
  • Session location: Sessions are the part most likely to log users out when a store moves. Test a restart during a simulated login load.
  • Backups: Caches are rebuilt, not restored. Sessions are transient. Confirm what, if anything, your backup policy must cover in the shared store.
  • Network placement: The shared store should sit on a private network with access limited to Moodle nodes. Confirm authentication settings for your chosen version.

Before choosing, check the cache and session configuration for your target release and load test a failover of the shared store.

How to tune a Moodle site in order

This sequence moves from measurement to targeted changes, so each tuning decision rests on evidence and can be reversed if it does not help. The output is a tuned site with recorded before-and-after results and a documented baseline for the next exam period.

  1. Baseline the current site and logs

    The administrator records how the site performs today before changing anything. Collect response times for key pages (course view, quiz attempt, gradebook, file download), PHP-FPM and web server logs, slow query logs from the database, and Moodle's own performance and task reports. Note peak concurrent users and when they occur. Done means a written baseline with at least one repeatable load run that every later step can be compared against.

  2. Confirm PHP and database versions against the target release

    Before tuning, check that the runtime matches the Moodle version you plan to run. Moodle 5.1 requires 64-bit PHP 8.2 or later (8.3 and 8.4 supported) and PostgreSQL 15, MySQL 8.4, MariaDB 10.11 or SQL Server 2017 or later. Moodle 5.3 requires 64-bit PHP 8.3 or later (8.4 supported), PostgreSQL 17, MySQL 8.4, MariaDB 11.4 or SQL Server 2019 or later. Tuning settings on an unsupported runtime wastes effort, so this step must close before the next one. Done means a version inventory signed off against the release notes for your target.

  3. Tune PHP and opcache

    Adjust the PHP-FPM process pool so the number of workers fits the memory available on each web node, and enable and size opcache so compiled Moodle code stays in shared memory. Review memory_limit, max_execution_time and the upload limits against the largest activities and uploads your users actually run. Change one group of settings at a time. Done means the same load test from the baseline is re-run, with response times, memory use and error counts recorded against the baseline.

  4. Tune the database and its connections

    Review the database server's memory allocation, connection limits and slow query log, and confirm the Moodle database user is configured for the expected connection count. Check that indexes and table statistics are current, and that any long-running reports or cron queries are identified. Ask your Moodle partner or database administrator to confirm engine-specific settings for your version, since these differ between PostgreSQL, MySQL, MariaDB and SQL Server. Done means the slow query list has been reviewed and the top queries are either fixed or accepted, with a load test showing the effect.

  5. Configure cache stores and session handling

    Moodle's MUC cache stores hold application data, and sessions can be kept in files, the database or a dedicated store. Under multiple web nodes, confirm that the chosen cache and session backends are shared and reachable by every node, because local file caches will show inconsistent results. Set session timeouts to match your exam policies. Done means cache store and session configuration is documented per node, and a test with logged-in users across two nodes shows no lost sessions or stale content.

  6. Separate and size cron and ad hoc task workers

    Moodle runs scheduled tasks through cron and queued work through ad hoc tasks. Run cron from a single controlled scheduler rather than from web requests, and check the scheduled task and ad hoc task queues during normal use and during simulated exam load. Long-running tasks such as report generation or bulk enrolment syncs should not block assessment traffic. Done means a task queue review shows queue depth, task runtimes and failures over a full working day, and any task that delays users has a documented schedule or dedicated worker.

  7. Move or verify file serving

    Confirm how moodledata and course files are served. Large files served through PHP consume worker time that should go to page requests, so check whether the web server or a shared storage layer can serve files directly, and confirm that the web server document root matches the release. From Moodle 5.1, the document root must point to the /public directory, otherwise the site may show directory listings or errors. Done means a file download test on large course files shows acceptable times and the document root check is recorded.

  8. Re-test under exam-level load and record results

    Run the same load scenarios from the baseline against the tuned site, including a simulated peak with concurrent quiz attempts and gradebook access. Compare response times, error rates, database load and task queue depth with the baseline numbers. Any step that did not improve results should be reversed. Done means a dated report with before-and-after figures, a list of accepted limits, and a retest schedule before the next exam period.

How cron and ad hoc tasks slow exam-day sites

Moodle runs two kinds of background work, and exam-day planning has to account for both. Scheduled cron tasks run on a timetable, such as sending queued notifications, refreshing caches, and cleaning up old data. Ad hoc tasks are queued by user actions: course backups, restores, grade recalculation, report generation, and bulk enrolment operations. Scheduled tasks are usually predictable. Ad hoc tasks are not, because a single lecturer or administrator can queue a heavy job at the same moment hundreds of students are logging in to sit an assessment. The task queue is shared, so a long-running job or an undersized worker pool can delay the work students actually see, including page responses that depend on task output and the outgoing emails that carry their confirmations and reminders.

Symptoms usually appear as slow notifications, messages that arrive late, grades that lag behind submissions, or a queue that grows faster than it drains. The cause is often a small number of expensive tasks competing for the same database and PHP capacity as the web tier. Moodle's cron and task runner settings, including how many workers run and how long each one may process, control how much of that capacity background work can consume. Confirm the exact cron and worker configuration against the Moodle documentation for the release you run, because the supported approach has changed across versions and the Moodle releases page lists the current support windows you should check before you plan.

The practical fix is to measure before the exam window and test under controlled load. Record how many ad hoc tasks are queued at normal times and at peak, how long the longest backup or report jobs take, and how far email delivery trails submission. Then run a rehearsal that combines concurrent logins, assessment submissions, and a realistic set of administrative jobs, and confirm that worker capacity clears the queue within the time your assessment rules allow. Agree in advance who may queue heavy jobs during an exam window and schedule backups for outside it. Illustrative example: if a rehearsal shows a backup blocking the queue for the duration of a timed quiz, the fix is a scheduling rule and a worker change, not a larger web tier.

What drives tuning effort and how to keep it down

This table lists the factors that most change how much tuning work a Moodle site needs, why each one raises effort, and what to do about it. Read it before scoping a load test or asking for a quote, since the biggest drivers are usually peak concurrency and the custom code running on every page.

DriverWhy it raises effortHow to reduce it
Concurrent users at peakPeak logins, quiz attempts and page loads stress PHP workers, database connections and session storage at the same moment, which hides bottlenecks found at normal load.Agree a peak concurrency figure with the academic calendar owner, then test against it. Confirm the expected peak with your own usage reports, not estimates.
Data volume and file storage sizeLarge course databases, log tables and moodledata directories slow backups, cleanup tasks and queries that scan big tables.Set log and cache retention, schedule cleanup outside teaching hours, and review large course files before go-live. Keep big media on suitable storage.
Number of web nodesEach added node multiplies configuration points for PHP, caches, sessions and shared moodledata, and makes inconsistent settings a common failure.Standardize one configuration template for all nodes, and confirm that cache and session stores are shared rather than local before adding capacity.
Custom plugins and themes that add queriesCustom blocks, reports or theme code that run on every page can add database queries and template work that scale with users, and they often escape early testing.Profile pages with Moodle's built-in debugging and profiling tools, review custom code against core APIs, and cache expensive output where the API allows it.
Integrations that call Moodle during logins or enrolmentsIdentity, HR or student information system calls during sign-in or bulk enrolment can queue up at the same time as peak traffic and lock or slow the database.Move bulk enrolment and sync to scheduled jobs outside peak periods, and load test login flows with the integrations switched on.
Number of environments (test, staging, production)Each environment needs matching PHP, database, cache and data sizes to produce useful results, and drift between them makes test results unreliable.Keep configuration under version control, use a recent anonymized copy of production data for tests, and document where test results do not match production.
Compliance evidence neededAssessors and institutional reviewers may ask for test plans, performance results, retention settings and change records, which adds documentation work to each change.Define the evidence list at scoping, keep test results and configuration changes in a single record, and confirm the required format with your compliance team.

How Moodle layers fit together under load

The diagram starts with learner requests arriving over the public network at a load balancer, which hands them to several web nodes running PHP. Those nodes are the trust boundary: everything to the right sits in the private application and data tier. Each web node reads and writes the database, the shared cache and session stores, and moodledata file storage, while a separate pool of cron and ad hoc task workers runs scheduled and queued work against the same database and file storage. When you tune for an exam period, check each arrow: whether the cache and sessions are shared across nodes, whether the database can absorb peak connections, and whether background workers compete with learners for the same resources.

Learner traffic and background task workers sharing one private database and file tier.

Securing caches, sessions and task workers

Caches, session stores and task workers are the parts of a Moodle stack that make it fast, and they are also the parts most often left open or over-shared. The four controls below cover network exposure, credential handling, file access and web server configuration, and each one should be checked before a performance test is treated as representative.

Restrict cache and session network access

Redis, Memcached and similar stores used for MUC caches and sessions should accept connections only from the Moodle web and cron nodes. Bind them to private interfaces, put them on a private subnet or security group, and require authentication where the store supports it. Confirm the firewall rules from a host outside the application tier, because a cache reachable from the internet can expose session data and be used to tamper with cached content.

Moodle plugin types

Keep credentials out of shared config

Database passwords, cache credentials and SMTP secrets should come from the server environment or a secret manager, not from a config.php copied between teams or committed to version control. Restrict file permissions so only the web and cron service accounts can read the config, and rotate credentials when an administrator leaves. Ask your hosting or platform team how secrets are injected into each web node, since drift between nodes causes intermittent cache and session failures.

Limit access to moodledata

The moodledata directory holds uploaded files, backups and temporary data, and it should not be reachable through the web server at all. Mount it on storage that only Moodle nodes can read and write, and set ownership so other local users cannot browse it. Serve files only through Moodle's own file handling so that access checks run on every request. Test by requesting a known file path directly in a browser and confirming a refusal.

Set the document root for the release

From Moodle 5.1 the web server document root must point to the /public directory rather than the main Moodle folder. A root left at the old location can expose directory listings, source files or error pages, and the mistake often survives a restart because the site still appears to work. After every upgrade, check the virtual host configuration against the release notes and confirm that PHP files outside /public are not served directly.

Moodle 5.1 release notes

How to load test Moodle before an exam period

Load testing answers one question before the exam window opens: can the current Moodle architecture serve the peak your own exam schedule will create, with headroom to spare? The test must start from a production-like copy of the site, with the database and moodledata volumes close to what the institution holds today, including the course, quiz attempt and file counts that drive query cost. Build the copy on the same PHP version, web server, cache stores, session handler and cron arrangement as production, because a test on a smaller or differently configured stack measures a different system. Take the peak targets from the institution's own timetable: concurrent quiz attempts per start time, the number of learners opening the same course page within minutes, and the submission window for assignments. Do not borrow a peak from another institution's numbers.

Script realistic learner journeys rather than hammering a single URL. A typical script logs in through the real authentication path (including SSO if it is in production), opens a course page, starts a quiz, saves responses, submits an assignment file and checks the grade page. Ramp the virtual user count in steps toward the target peak, hold it there long enough to reach steady state, then continue to a headroom level above the target. During each step, watch response times at the percentile level rather than the average, the HTTP error rate, the length of the ad hoc and scheduled task queue, the number of open database connections, and cache and session store latency. Record a baseline run at normal term-time load first, so every later result is compared against the same scripts, data and configuration.

Failure testing is a separate exercise from load testing. With the load running at a moderate level, stop one web node or the cache service and confirm that users are routed away from the failed component, that quiz attempts in progress are not lost, and that the site recovers when the component returns. Check that moodledata writes and the session store behave as designed during the outage. Confirm the expected behavior with your own architecture team and with the vendor documentation for each cache and database product you run, since failover details depend on that configuration. Keep the findings, the retest results and the agreed fixes in a dated record so the exam operations team can show what was tested before the window opens.

What to monitor, back up and document after tuning

This table lists what to watch after performance tuning, how often to check it, and what the runbook should record for each area. Read it as a baseline for the operations team: the first column names the component, and the other two set the review cadence and the documentation the next administrator will need. Support dates for each Moodle release belong in the same runbook, because the upgrade window depends on them.

ComponentHow oftenWhat to keep in the runbook
PHP-FPM and web server metricsContinuously, with daily review during exam periodsPool sizes, max children, request queue length, 5xx counts and the baseline values captured during load testing
Database slow queries and connectionsContinuously, with a weekly slow query reviewSlow query log settings, top recurring queries, connection limits, and any index or config changes with their dates
Cache and session store healthContinuously, with a check after every configuration changeCache store assignments by definition, session store location, eviction or timeout settings, and restart procedures
Ad hoc task queue depth and failed tasksEvery cron cycle during exam periods, daily otherwiseCron schedule, number of task runners, the failed task list, and the steps used to clear or rerun stuck tasks
moodledata disk growthWeekly, with a capacity projection before each termCurrent size, monthly growth trend, file storage location, and the cleanup or archival rules agreed with the business owner
Moodle release and security support datesQuarterly, and before each planned upgradeInstalled version, PHP and database versions, and the support end dates from the Moodle releases page, such as 5.1 security support until 19 April 2027
Backups and restore testsDaily backup jobs, with a restore test on a schedule the team setsBackup scope covering database, moodledata and code, retention period, last successful restore test and its result

Questions buyers ask about Moodle performance tuning

How much does Moodle performance tuning cost?

The cost depends on the size of the site, how many users sit on it at peak, and how many customizations and plugins it already runs. A tuning engagement is usually priced from a written scope, and no figure can be stated responsibly without knowing the environment. The main cost components are the time spent measuring the current site, the changes to PHP, the database, caching and cron, the load tests themselves, and the report that explains what changed. Ask for a quote that lists each of these as a separate line, states what is one-time work, and states what recurs, such as retesting before each exam period or after each upgrade. Ask whether infrastructure changes, such as larger servers, are included or billed separately, since those costs are paid to the hosting provider rather than to the tuning work.

How long does a Moodle load testing cycle take?

It depends on scope, and the duration should be confirmed in a written plan before work starts. The length is driven by how many environments need testing, how much realistic course and user data is available, how many user journeys the test must cover, and how many rounds of tuning and retesting are needed to reach the target. Teams often underestimate the time spent reproducing peak conditions, such as quiz submissions and grade views happening at the same moment. Ask the provider to break the plan into phases: baseline measurement, tuning changes, retests and final reporting. Also ask how the schedule accounts for the exam calendar, since the test window must finish well before the first high-load session.

What does the institution need to provide for tuning work?

The institution provides the access, the information and the decisions that the tuning team cannot make alone. Access means credentials to the web servers, database, cache and cron hosts, and the Moodle administrator account, along with a staging environment that resembles production. The exam calendar, expected peak concurrency and the most used activities, such as quizzes or assignment submissions, shape the test scenarios. Test data should be representative in size and structure, and it must be handled under your data protection rules. Finally, name one owner who can approve configuration changes, accept trade-offs such as longer cache lifetimes, and sign off the results. Without that owner, findings often stall.

Can our internal team tune Moodle without a partner?

Yes, a capable internal team can tune Moodle, provided it has people who understand PHP-FPM, the database engine, Moodle's cache stores and session handling, and how cron and ad hoc tasks run. The harder part is usually the load testing: building realistic scenarios, running them repeatably, and separating a real bottleneck from noise. Check whether your team has done this before for a learning platform, and whether it can keep the work going through the next Moodle upgrade. A partner adds value mainly by bringing a tested method and a second set of eyes, and by taking on the documentation. Many organizations split the work, keeping day-to-day operations in house and bringing in outside help for the initial baseline and the pre-exam tests.

What changes for performance after a Moodle upgrade?

An upgrade can change performance in both directions, so tuning should be repeated after each major version rather than assumed to carry over. Each release has its own requirements for PHP and the database, and those versions affect how queries and opcode caching behave. For example, Moodle 5.1 requires 64-bit PHP 8.2 or later, and Moodle 5.3 requires 64-bit PHP 8.3 or later, with PostgreSQL 17 among the supported database versions for 5.3. Moodle 5.1 also changed the web server document root to the /public directory, and a misconfigured root can break the site before performance is even measured. Plugins may add their own queries or cron tasks, so re-test any that changed. Plan a fresh load test on a staging copy of the upgraded site before the next exam period.

Which Moodle settings have the biggest effect on speed?

The biggest gains usually come from a few areas: PHP-FPM worker sizing and OPcache, database connections and query indexes, the cache store configuration, session storage, and how often cron and ad hoc tasks run. Moodle's caching layer can use dedicated stores such as Redis or Memcached, and sessions can be moved out of the file system so that several web nodes share them. Cron should run on a schedule that does not compete with peak exam load, and ad hoc task workers should be sized so queued jobs such as grade exports or backups do not stall user requests. File storage matters too, since large course files served from a slow share add latency. Each change should be tested alone so its effect is measured, and the settings chosen should match the supported PHP and database versions for your release.

How do we know tuning worked before an exam period?

You know it worked when a repeatable load test, run against a staging copy that matches production, meets the response and error targets your team agreed in advance. Those targets should be written down before testing starts, including the peak concurrency, the key user journeys such as logging in, opening a quiz and submitting answers, and the acceptable response times for each. Repeat the same scenario after each change so the results can be compared. Keep a rollback plan for every configuration change, and rehearse it. Ask the provider for a written report that lists the baseline, each change, the retest result and any limits that remain, so the owner can decide whether to go ahead before the exam calendar begins.

How DeployOpen scopes and hands over Moodle performance work

DeployOpen performs Moodle performance work on self-hosted Moodle inside your own environment: your cloud accounts, your data center or your air-gapped network. The Moodle instance, its database, its moodledata storage, its cache and session servers and its cron workers stay under your control throughout. Because the work touches production infrastructure that your teams will own afterward, it is scoped and agreed in writing before any change is made. A fixed-scope engagement for this topic normally covers four deliverables: a baseline measurement of current response times, database and cron behavior under realistic load, the tuning changes themselves (PHP settings, database configuration, cache store assignment, session handling and task scheduling), and load tests that repeat before each exam period.

The written scope should name the environment, the Moodle version and the database engine in use. Moodle 5.1 requires 64-bit PHP 8.2 or later and supported databases such as PostgreSQL 15 or MySQL 8.4, and Moodle 5.3 raises the minimum PHP and database versions, so confirm which release you run before scoping. Ask the provider to list each change, the environment where it is tested, the metrics used to judge success and the runbook and handover documents you will receive. Also confirm which items sit outside the fixed scope, such as third-party plugin fixes, storage hardware or network changes. DeployOpen does not publish a price list. A quote follows from the written scope, so the more precisely you define the load profile, environment and handover deliverables, the more precise the quote will be. Ongoing support, upgrades and repeat load testing are available as retainers, and you should decide early whether you want that cover or prefer your own team to run the exam-period checks. DeployOpen is a Chainscore Labs company. It prepares systems and evidence, but it does not issue audit reports or certifications, so any independent assurance on your hosting must come from a qualified assessor.

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.