Performance Optimization Guide

Version: 1.2.1 Last Updated: December 2025 Difficulty: Intermediate Time Required: 30 minutes

Overview

While Attributes User Access is optimized for performance, high-traffic sites and large user databases can benefit from additional configuration. This guide covers caching strategies, database optimization, and load reduction techniques.

Performance Metrics

What to Monitor

Key indicators:

✓ Page load time (target: < 2 seconds)
✓ Database queries per page (target: < 50)
✓ Memory usage (target: < 64MB per request)
✓ Login page response time (target: < 1 second)
✓ CPU usage during peak traffic
Tools for monitoring:
  • Query Monitor plugin
  • New Relic
  • GTmetrix
  • Google PageSpeed Insights
  • Server logs

Database Optimization

Issue: Slow Queries on Large User Base

For sites with 10,000+ users: Add database indexes:

-- Speed up user meta lookups
ALTER TABLE wp_usermeta ADD INDEX idx_meta_key_value (meta_key, meta_value(50));

-- Speed up audit log queries
ALTER TABLE wp_attrua_audit_log ADD INDEX idx_timestamp (timestamp);
ALTER TABLE wp_attrua_audit_log ADD INDEX idx_user_id_timestamp (user_id, timestamp);
ALTER TABLE wp_attrua_audit_log ADD INDEX idx_event_type (event_type);
Backup database before running ALTER TABLE commands!

Clean Up Old Audit Logs

Automatically purge old logs:

Users → Audit Log → Settings

Auto-Cleanup:

☑ Enable automatic log cleanup

Retain logs for: [90] days

Run cleanup: [Daily] at [2:00 AM]

For compliance: Keep 1 year minimum

For performance: 90 days sufficient

Manual cleanup:

-- Delete logs older than 90 days
DELETE FROM wp_attrua_audit_log 
WHERE timestamp < DATE_SUB(NOW(), INTERVAL 90 DAY);

-- Optimize table after deletion
OPTIMIZE TABLE wp_attrua_audit_log;

Optimize User Meta Storage

Remove orphaned metadata:

-- Find usermeta rows for deleted users
SELECT COUNT(*) FROM wp_usermeta um
LEFT JOIN wp_users u ON um.user_id = u.ID
WHERE u.ID IS NULL;

-- Delete orphaned meta (be careful!)
DELETE um FROM wp_usermeta um
LEFT JOIN wp_users u ON um.user_id = u.ID
WHERE u.ID IS NULL;

Caching Strategies

Object Caching

Enable persistent object cache: Install Redis or Memcached:

<h1>Check if available on your server</h1>
php -m | findstr redis
php -m | findstr memcached
Install object cache plugin:
  • Redis Object Cache (recommended)
  • Memcached Object Cache
  • W3 Total Cache (includes object caching)
Configure for Attributes:

// wp-config.php
define('WP_CACHE', true);
define('WP_CACHE_KEY_SALT', 'yoursite.com');
Benefits:

Before: Database query for each user meta lookup

After: Cached in memory, 10-100x faster

Page Caching Exclusions

Never cache these pages:

Pages to exclude:

/login/

/my-account/

/dashboard/

/user-profile/

Any page with [attrua_login]

Any page with [attrua_register]

/wp-admin/

/wp-login.php

WP Rocket configuration:

Settings → Advanced Rules → Never Cache URL(s)

Add:

/login(.*)

/my-account(.*)

/dashboard(.*)

W3 Total Cache:

Performance → Page Cache → Advanced

Never cache the following pages:

/login/

/my-account/

/dashboard/

Login Page Specific Optimizations

Disable caching via code:

// Add to login page template or functions.php
if (is_page('login')) {
    define('DONOTCACHEPAGE', true);
    header('Cache-Control: no-cache, no-store, must-revalidate');
    header('Pragma: no-cache');
    header('Expires: 0');
}

Reduce Query Load

Lazy Load User Data

Don’t load unnecessary user meta:

// In custom themes/plugins
// Instead of get_userdata() which loads ALL meta:
$user = get_user_by('id', $user_id);

// Get only what you need:
$specific_meta = get_user_meta($user_id, 'specific_key', true);

Disable Unused Features

Turn off features you don’t use:

Users → Login Settings → Features

Disable if not needed:

☐ Audit logging (significant performance impact)

☐ IP geolocation (requires external API calls)

☐ Advanced rate limiting

☐ Automatic IP blocking

☐ Email notifications for every login

Performance impact:

Feature disabled → Performance gain

Audit logging → 20-30% faster

IP geolocation → 10-15% faster

Rate limiting → 5-10% faster

Optimize Audit Logging

Reduce events logged:

Users → Audit Log → Settings

Log these events only:

☑ Failed login attempts

☑ Successful admin logins

☑ Security setting changes

☑ User role changes

Don’t log:

☐ Every successful login

☐ Every page view

☐ Every logout

☐ Profile updates

Server Configuration

PHP Configuration

Optimal PHP settings:

; php.ini or .user.ini

memory_limit = 256M
max_execution_time = 60
max_input_time = 60
post_max_size = 64M
upload_max_filesize = 64M

; OPcache (significant performance boost)
opcache.enable=1
opcache.memory_consumption=128
opcache.max_accelerated_files=10000
opcache.revalidate_freq=60

Enable OPcache

Verify OPcache enabled:

<?php // Create info.php in site root
phpinfo();
// Visit: https://yoursite.com/info.php
// Search for "opcache"
// Delete file after checking!
If OPcache not enabled:
  • Contact hosting provider
  • Or enable in php.ini (if you have access)
  • Performance improvement: 30-70% faster

Database Server Optimization

MySQL/MariaDB tuning:

; my.cnf or my.ini

innodb_buffer_pool_size = 1G  ; Increase for more RAM
query_cache_size = 64M
query_cache_type = 1
max_connections = 200
thread_cache_size = 8
table_cache = 64
Contact hosting provider to optimize database configuration. These settings require server access.

Load Balancing

For High-Traffic Sites

Multiple server considerations: Session handling:

// Use database sessions for load balancing
// wp-config.php
define('WP_CACHE_KEY_SALT', $_SERVER['HTTP_HOST']);

// Or use Redis for sessions
ini_set('session.save_handler', 'redis');
ini_set('session.save_path', 'tcp://127.0.0.1:6379');
Centralized user database:

All servers must connect to same database

Use master-slave replication for reads

Keep audit logs in separate database

CDN Configuration

Content Delivery Network Setup

Cloudflare configuration:

Page Rules for login pages:

Rule 1: yoursite.com/login

  • Cache Level: Bypass
  • Disable Security
  • Disable Apps

Rule 2: yoursite.com/my-account

  • Cache Level: Bypass

Rule 3: yoursite.com/wp-admin

  • Cache Level: Bypass
Why bypass CDN for auth pages:

✗ CDN caching login forms = users see cached content

✗ HTTPS via CDN may break form submissions

✗ Security headers may conflict

✓ Direct connection faster for auth anyway

Code-Level Optimizations

Reduce HTTP Requests

Combine assets:

// functions.php
add_action('wp_enqueue_scripts', function() {
    // Only load plugin CSS/JS on pages that need it
    if (!is_page('login')) {
        wp_dequeue_style('attrua-login-styles');
        wp_dequeue_script('attrua-login-script');
    }
});

Lazy Load Non-Critical Resources

Defer JavaScript:

// Defer non-critical scripts
add_filter('script_loader_tag', function($tag, $handle) {
    if ('attrua-dashboard' === $handle) {
        return str_replace(' src', ' defer src', $tag);
    }
    return $tag;
}, 10, 2);

Monitoring Performance

Query Monitor Setup

Install Query Monitor plugin:
  • Install “Query Monitor” from WordPress.org
  • Activate plugin
  • Visit login page
  • Check toolbar for query count and time
What to look for:

✓ Total queries: < 50 per page

✓ Slow queries: < 0.05 seconds each

✓ Duplicate queries: None

✓ Memory usage: < 64MB

Performance Benchmarks

Target metrics by site size: Small site (< 1,000 users):

Login page load: < 1 second

Database queries: < 30

Memory: < 32MB

Medium site (1,000-10,000 users):

Login page load: < 2 seconds

Database queries: < 50

Memory: < 64MB

Object caching: Recommended

Large site (10,000+ users):

Login page load: < 2 seconds

Database queries: < 50

Memory: < 128MB

Object caching: Required

Database indexes: Required

CDN: Recommended

Troubleshooting Slow Performance

Diagnostic Checklist

  • Check PHP version (7.4+ minimum, 8.0+ recommended)
  • Verify OPcache enabled
  • Install Query Monitor, check slow queries
  • Add database indexes for large sites
  • Enable object caching (Redis/Memcached)
  • Clean up old audit logs
  • Disable unused features
  • Exclude auth pages from page caching
  • Test with default theme (theme conflict check)
  • Deactivate other plugins (plugin conflict check)

Best Practices

Measure Before and After

Use GTmetrix or Query Monitor to benchmark before optimizing. Track improvements.

Optimize Database Regularly

Monthly cleanup of audit logs and orphaned data keeps database lean.

Use Object Caching

Redis or Memcached provides biggest performance boost for user-heavy sites.

Don’t Cache Auth Pages

Always exclude login, registration, and account pages from caching.