| Area | Sub‑Area | Action Items |
|---|---|---|
| 0) Readiness & Goals | SLOs & Metrics | Define business SLOs, Core Web Vitals, establish baselines, create dashboards, prepare test data |
| Profiling | Enable APM/Tracing, endpoint heatmaps, profilers, DB slow query logs, Lighthouse runs | |
| 1) Quick Wins | Immediate Optimizations | Enable compression, cache static assets, use CDN, connection reuse, image optimization, lazy-load, fix N+1 queries |
| A) Application Layer | Framework Settings | Production mode, config/route/view cache, autoloader optimization, template caching, DTO optimization, pagination, compression |
| Code Quality | Remove N+1 queries, memoization, async external calls, circuit breakers/timeouts, reduce payloads, early validation, idempotency | |
| Language-Specific | PHP: OPcache, Octane, Horizon, Redis, Eloquent optimizations; Spring Boot: JVM heap, GC, HikariCP tuning, Actuator; Flask: gunicorn/uwsgi tuning, async; Node.js: clustering, connection pools, monitor event loop | |
| API Design | Idempotent GETs, PATCH for partial updates, ETags, rate limits, batch endpoints | |
| B) Backend Runtime | General | LTS runtimes, JIT/OPcache, minimal base images, container resource limits, warm-up strategies |
| C) Frontend | Web Assets | Lighthouse audits, bundle splitting, tree-shaking, minification, HTTP/2 or 3, critical CSS inlined, preload/preconnect, font optimization, Service Worker caching, limit 3rd-party scripts |
| D) Database | SQL Engine | Correct engine, buffer pool sizing, connection pools, indexing, query rewrites, replicas for reads, caching, analyze/vacuum/optimize, backup & recovery |
| E) Caches & Messaging | Redis/Memcached, Queues | Namespaces & TTLs, cache stampede protection, CDN caching, message queues for async tasks |
| F) Web Server/Proxy | Nginx/Apache/Tomcat | Worker tuning, keep-alive, compression, serve static via CDN, health checks, TLS optimization |
| G) Operating System | Linux/Windows | Increase ulimit, kernel TCP tuning, adjust swappiness, disable THP, NUMA tuning, time sync |
| H) Network & Dependencies | Latency Reduction | DNS latency check, TLS optimization, connection pooling, audit third-party APIs |
| I) Observability & Guardrails | Monitoring | Centralized logging, RED/USE dashboards, SLO alerting, exception tracking, feature flags, canaries |
| J) Load & Resilience Testing | Testing | Define load/stress/spike/soak tests, tools (k6, JMeter, Locust), capture capacity curves, chaos experiments |
| K) Cloud/Infra | Kubernetes/VMs | Right-size instances, autoscaling, pod requests/limits, node locality, service mesh overhead review |
| L) Data Shape & Storage | Payload/Data | Cap payloads, compress responses, use object storage, partition large tables, archival policies |
| M) Security vs Performance | Secure & Fast | WAF/CDN profiling, JWT size control, efficient crypto, TLS offload at edge |
| N) CI/CD & Governance | DevOps | Performance budgets in CI, regression tests, DB migration rehearsals, release changelogs with perf notes |
| O) Playbooks & Runbooks | Incident Mgmt | High latency runbooks, DB emergency actions, cache outage mitigation |
| P) Verification | Post-Changes | Before/after metrics comparison, user-visible improvements validated, update capacity plan |
| Appendix: Laravel | Optimization | Config/route/view cache, Octane with Swoole, Eloquent optimizations, Redis for cache/session/queue |
| Appendix: Spring Boot | Optimization | HikariCP tuning, G1/ZGC, JFR, Undertow/Netty, Micrometer + Prometheus/Grafana |
| Appendix: Flask | Optimization | Gunicorn tuning, preload, async frameworks, template caching |
| Appendix: MySQL/MariaDB | Optimization | Buffer pool/log sizing, slow query log, indexing, duplicate index cleanup |
| Appendix: Nginx/Apache/Tomcat | Optimization | Worker tuning, Brotli, static serving via CDN, Tomcat thread tuning |
| Appendix: Linux | Sysctl & Limits | Ulimit ≥ 65535, sysctl tuning, swappiness, disable THP |
0) Readiness & Goals
since you’re on XAMPP + Laravel + PHP + MySQL + Linux, and you want SLIs (latency, error rate, throughput) & metrics just in your Dev environment, you don’t need enterprise-grade APMs like New Relic yet. Laravel/PHP has some native and lightweight options that can give you per-request response time, DB query timings, and code profiling.
Here’s a structured set of recommendations:
🔹 Native / Laravel-Friendly Tooling
1. Laravel Telescope (Official)
- What it does:
- Profiles each request (execution time, memory, status code).
- Shows all queries with timing, N+1 warnings, slow query detection.
- Displays jobs, cache hits/misses, exceptions, mail, logs, etc.
- Why good for Dev: Easy to install, beautiful dashboard, zero external infra.
- Install:
composer require laravel/telescope --dev php artisan telescope:install php artisan migrate php artisan serve - Accessible at
/telescopein dev.
2. Laravel Debugbar
- What it does:
- Adds a debug toolbar at the bottom of each page.
- Shows request duration, memory usage, DB queries with time.
- Highlights slow queries and duplicate queries.
- Why good for Dev: Extremely lightweight, immediate visibility.
- Install:
composer require barryvdh/laravel-debugbar --dev
3. Clockwork
- What it does:
- Adds Chrome/Firefox extension for profiling Laravel requests.
- Records request duration, queries, cache, events, logs, timeline.
- More “developer-friendly” than Debugbar because it integrates with browser dev tools.
- Install:
composer require itsgoingd/clockwork --dev php artisan vendor:publish --tag=clockwork-config - View in Clockwork browser extension or
/__clockworkendpoint.
4. XHProf / Tideways / Blackfire (Low-Level Profilers)
- What they do:
- Provide per-function and per-line profiling.
- Show CPU time, memory usage, call counts.
- Help track bottlenecks beyond queries (e.g., loops, serialization).
- Why good for Dev: Deeper insight when Laravel Telescope/Debugbar isn’t enough.
- Options:
- XHProf (free, simple, supported by XHGUI web UI).
- Tideways/XHProf fork (better maintained).
- Blackfire.io (commercial but free Dev tier).
🔹 Metrics & SLI Extraction
Since you want SLIs (latency, error rate, throughput), you can:
- Use Laravel Telescope / Debugbar Data
- Export query logs & request timings → store in Prometheus/Grafana (optional).
- Laravel Prometheus Exporter
- Package:
superbalist/laravel-prometheus-exporter. - Exposes a
/metricsendpoint for Prometheus with:- Request duration histogram
- Query count & time
- Cache hits/misses
- Jobs queued/processed
- Package:
- Self-hosted Grafana + Prometheus (optional for Dev)
- Pull
/metricsendpoint. - Create SLI dashboards:
- Latency:
http_request_duration_secondsp95, p99. - Error rate:
http_requests_total{status="5xx"} / http_requests_total. - Traffic: requests/sec.
- Latency:
- Pull
✅ Suggested Dev Setup (Practical & Lightweight)
- Start with Laravel Telescope → best native tool for queries + request profiling.
- Add Clockwork or Debugbar → for real-time in-browser visibility.
- If you want structured SLI metrics → add Laravel Prometheus Exporter and run Prometheus + Grafana in Docker.
- For deeper profiling → plug in XHProf/XHGUI when you hit complex bottlenecks.
👉 My recommendation:
- Use Telescope + Debugbar for day-to-day dev.
- Add Prometheus Exporter only if you want a Grafana SLI dashboard.
- Keep XHProf/XHGUI in your toolkit for deep-dive debugging.
Database
Great question. Here’s a practical, safe set of MySQL/MariaDB settings you can enable/tune to process queries efficiently and avoid CPU/memory blow-ups, tailored for a web app (Laravel/PHP) on InnoDB. I’ve grouped them by purpose and included suggested starting values plus a ready-to-drop my.cnf template. (Use InnoDB everywhere; avoid MyISAM for OLTP.)
Key principles (before you tune)
- Prefer InnoDB; set proper memory split: big “global” InnoDB cache, small “per-connection” buffers (to avoid RAM spikes).
- Keep max_connections realistic; too high → memory explosion under load.
- Turn on slow query log and fix queries/indexes first—it’s the biggest win.
A) Core InnoDB memory & durability
| Setting | What it does | Starting point (single DB server) | Notes |
|---|---|---|---|
innodb_buffer_pool_size | Main data+index cache | 60–70% of RAM (DB-only host) | Largest lever for CPU (less I/O). |
innodb_buffer_pool_instances | Concurrency in buffer pool | 1 per ~8–16GB (e.g., 2 for 16GB) | Don’t overdo; 1–8 is typical. |
innodb_log_file_size | Redo log size | 1–4GB total (e.g., 2×1GB) | Bigger = fewer flushes; faster writes. |
innodb_log_buffer_size | Buffer for redo before flush | 64–256MB | Helps heavy write bursts. |
innodb_flush_log_at_trx_commit | Durability vs speed | 1 (full ACID) or 2 (faster dev) | 2 reduces fsyncs (OK in dev). |
innodb_flush_method | Flush mode | O_DIRECT (Linux) | Helps avoid double buffering. |
innodb_file_per_table | Tablespaces | ON | Default; good for space and manageability. |
innodb_flush_neighbors | SSD optimization | 0 (on SSD/NVMe) | Reduces extra flush work. |
B) Concurrency & CPU
| Setting | What it does | Starting point | Notes |
|---|---|---|---|
MariaDB thread_pool=ON | Thread pool (caps active threads) | ON | Great at preventing CPU thrash (MariaDB only). |
innodb_thread_concurrency | InnoDB internal concurrency | 0 (auto) | Let InnoDB self-tune. |
table_open_cache | Open tables cache | 2000–4000 | Raise if “Opened_tables” increases quickly. |
table_definition_cache | Cached table defs | 2000 | Helps many tables/schemas. |
open_files_limit | Process file limit | >= 65535 | Aligns with table cache. |
skip-name-resolve | Avoid DNS on connect | Enable | Prevents connect latency spikes. |
C) Per-connection memory (prevent RAM blow-ups)
These allocate per connection. Keep them modest and keep max_connections realistic.
| Setting | Purpose | Starting point | Warning |
|---|---|---|---|
max_connections | Hard cap on sessions | 150–300 | Each conn can allocate MBs → memory spikes. |
tmp_table_size | Mem temp tables | 64–128MB | Pairs with max_heap_table_size. |
max_heap_table_size | In-RAM temp tables | 64–128MB | Don’t set wildly high. |
join_buffer_size | No-index joins | 256KB–1MB | Per-join, per-thread; keep small. |
sort_buffer_size | ORDER BY sorts | 512KB–2MB | Too big × many connections = OOM. |
read_buffer_size | Seq. scans | 512KB–1MB | Keep conservative. |
read_rnd_buffer_size | Random reads after sort | 256KB–1MB | Keep conservative. |
D) Optimizer & SQL safety
| Setting | What it does | Starting point | Notes |
|---|---|---|---|
sql_require_primary_key (MySQL 8+) | Enforce PKs | ON | Vital for InnoDB performance & replication. |
optimizer_switch | Plan tweaks | Defaults are fine | Focus on indexes first. |
innodb_autoinc_lock_mode | AUTO_INCREMENT contention | 2 | Better concurrency. |
E) I/O & background
| Setting | What it does | Starting point | Notes |
|---|---|---|---|
innodb_io_capacity | Flush/IO pacing | 200–800 (SATA) / 1000–4000 (NVMe) | Match device capability. |
innodb_read_io_threads | Parallel read threads | 4 | 4–8 typical. |
innodb_write_io_threads | Parallel write threads | 4 | 4–8 typical. |
innodb_adaptive_hash_index | Hot-range acceleration | ON (default) | Consider OFF if contention (rare). |
F) Logging & instrumentation
| Setting | Purpose | Suggested |
|---|---|---|
slow_query_log=ON | Capture slow queries | Turn on in dev and prod. |
long_query_time=0.2 | Slow threshold | 200ms (dev). 0.5–1s in prod. |
log_queries_not_using_indexes=ON | Find table scans | Use in dev (noisy in prod). |
performance_schema | Engine for metrics | Keep ON, but avoid enabling every consumer (memory!). |
G) Binary logs & timeouts (dev vs prod)
| Setting | Purpose | Dev | Prod |
|---|---|---|---|
skip-log-bin or log_bin | Binary logging | Disable if no replicas | Enable (HA/backups) |
sync_binlog | Crash safety for binlog | 0 | 1 (strong durability) |
wait_timeout | Idle conn close | 60–300s | 300–600s |
interactive_timeout | Idle interactive | 300–600s | 600–1800s |
H) MariaDB specifics (if you’re on MariaDB)
| Setting | Why | Value |
|---|---|---|
thread_pool=ON | Avoid CPU storms under load | ON |
| Query Cache | Causes contention | OFF (remove/disable) |
aria_pagecache_buffer_size | If using Aria tmp tables | Keep small; prefer InnoDB tmp tables |
Ready-to-use my.cnf template (Linux)
Adjust memory-sized values to your RAM. Example below assumes ~16GB host primarily for MySQL.
[mysqld]
# General
user = mysql
bind-address = 0.0.0.0
skip-name-resolve
sql_require_primary_key = ON
# InnoDB core
default_storage_engine = InnoDB
innodb_buffer_pool_size = 10G
innodb_buffer_pool_instances = 2
innodb_log_file_size = 1G
innodb_log_buffer_size = 256M
innodb_flush_log_at_trx_commit = 2 # 1 in prod for full durability
innodb_flush_method = O_DIRECT
innodb_file_per_table = 1
innodb_flush_neighbors = 0
innodb_autoinc_lock_mode = 2
innodb_io_capacity = 1000
innodb_read_io_threads = 4
innodb_write_io_threads = 4
# Concurrency & caches
table_open_cache = 4000
table_definition_cache = 2000
open_files_limit = 65535
max_connections = 250
thread_cache_size = 64
# Per-connection memory (keep conservative)
tmp_table_size = 128M
max_heap_table_size = 128M
join_buffer_size = 1M
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 1M
# Logging & instrumentation
slow_query_log = ON
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 0.2
log_queries_not_using_indexes = ON
performance_schema = ON
# Binary log (dev)
skip-log-bin
# For prod:
# log_bin = /var/lib/mysql/binlog
# sync_binlog = 1
# Timeouts
wait_timeout = 120
interactive_timeout = 600
Code language: PHP (php)
After changing redo log size (
innodb_log_file_size), stop MySQL cleanly, rename old ib_logfiles if needed (MySQL 5.7), then start.
How to confirm impact (quick checks)
- Memory planning (rule of thumb)
Total RAM ≈ innodb_buffer_pool_size + global overhead + (max_connections × per-connection buffers peak)
→ Keep buffers modest; don’t pushmax_connectionsbeyond what RAM allows. - Watch these during load:
SHOW GLOBAL STATUS LIKE 'Threads_connected';SHOW GLOBAL STATUS LIKE 'Opened_tables';(shouldn’t climb too fast)SHOW ENGINE INNODB STATUS;(check buffer pool hit rate, waits)EXPLAIN ANALYZE <query>(MySQL 8+/MariaDB), fix missing indexes.
- Tune iteratively: raise
table_open_cacheifOpened_tablesgrows; reduce per-connection buffers if memory spikes; if CPU high with many threads, MariaDBthread_pool=ON(or reducemax_connections).
Safe rollout order
- Turn on slow log and fix top queries/indexes.
- Set buffer pool (and redo log) to match RAM.
- Cap max_connections and shrink per-connection buffers.
- Enable skip-name-resolve, tune table caches.
- Consider thread pool (MariaDB) and I/O capacity.
- Re-test; iterate.
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals
Nice checklist! The app performance optimization tips are clear and practical — very useful for improving speed and user experience.