Turn Your Vehicle Into a Smart Earning Asset

While you’re not driving your car or bike, it can still be working for you. MOTOSHARE helps you earn passive income by connecting your vehicle with trusted renters in your city.

🚗 You set the rental price
🔐 Secure bookings with verified renters
📍 Track your vehicle with GPS integration
💰 Start earning within 48 hours

Join as a Partner Today

It’s simple, safe, and rewarding. Your vehicle. Your rules. Your earnings.

App Performance Optimization – Complete Checklist

AreaSub‑AreaAction Items
0) Readiness & GoalsSLOs & MetricsDefine business SLOs, Core Web Vitals, establish baselines, create dashboards, prepare test data
ProfilingEnable APM/Tracing, endpoint heatmaps, profilers, DB slow query logs, Lighthouse runs
1) Quick WinsImmediate OptimizationsEnable compression, cache static assets, use CDN, connection reuse, image optimization, lazy-load, fix N+1 queries
A) Application LayerFramework SettingsProduction mode, config/route/view cache, autoloader optimization, template caching, DTO optimization, pagination, compression
Code QualityRemove N+1 queries, memoization, async external calls, circuit breakers/timeouts, reduce payloads, early validation, idempotency
Language-SpecificPHP: 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 DesignIdempotent GETs, PATCH for partial updates, ETags, rate limits, batch endpoints
B) Backend RuntimeGeneralLTS runtimes, JIT/OPcache, minimal base images, container resource limits, warm-up strategies
C) FrontendWeb AssetsLighthouse 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) DatabaseSQL EngineCorrect engine, buffer pool sizing, connection pools, indexing, query rewrites, replicas for reads, caching, analyze/vacuum/optimize, backup & recovery
E) Caches & MessagingRedis/Memcached, QueuesNamespaces & TTLs, cache stampede protection, CDN caching, message queues for async tasks
F) Web Server/ProxyNginx/Apache/TomcatWorker tuning, keep-alive, compression, serve static via CDN, health checks, TLS optimization
G) Operating SystemLinux/WindowsIncrease ulimit, kernel TCP tuning, adjust swappiness, disable THP, NUMA tuning, time sync
H) Network & DependenciesLatency ReductionDNS latency check, TLS optimization, connection pooling, audit third-party APIs
I) Observability & GuardrailsMonitoringCentralized logging, RED/USE dashboards, SLO alerting, exception tracking, feature flags, canaries
J) Load & Resilience TestingTestingDefine load/stress/spike/soak tests, tools (k6, JMeter, Locust), capture capacity curves, chaos experiments
K) Cloud/InfraKubernetes/VMsRight-size instances, autoscaling, pod requests/limits, node locality, service mesh overhead review
L) Data Shape & StoragePayload/DataCap payloads, compress responses, use object storage, partition large tables, archival policies
M) Security vs PerformanceSecure & FastWAF/CDN profiling, JWT size control, efficient crypto, TLS offload at edge
N) CI/CD & GovernanceDevOpsPerformance budgets in CI, regression tests, DB migration rehearsals, release changelogs with perf notes
O) Playbooks & RunbooksIncident MgmtHigh latency runbooks, DB emergency actions, cache outage mitigation
P) VerificationPost-ChangesBefore/after metrics comparison, user-visible improvements validated, update capacity plan
Appendix: LaravelOptimizationConfig/route/view cache, Octane with Swoole, Eloquent optimizations, Redis for cache/session/queue
Appendix: Spring BootOptimizationHikariCP tuning, G1/ZGC, JFR, Undertow/Netty, Micrometer + Prometheus/Grafana
Appendix: FlaskOptimizationGunicorn tuning, preload, async frameworks, template caching
Appendix: MySQL/MariaDBOptimizationBuffer pool/log sizing, slow query log, indexing, duplicate index cleanup
Appendix: Nginx/Apache/TomcatOptimizationWorker tuning, Brotli, static serving via CDN, Tomcat thread tuning
Appendix: LinuxSysctl & LimitsUlimit ≥ 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 /telescope in 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 /__clockwork endpoint.

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:

  1. Use Laravel Telescope / Debugbar Data
    • Export query logs & request timings → store in Prometheus/Grafana (optional).
  2. Laravel Prometheus Exporter
  3. Self-hosted Grafana + Prometheus (optional for Dev)
    • Pull /metrics endpoint.
    • Create SLI dashboards:
      • Latency: http_request_duration_seconds p95, p99.
      • Error rate: http_requests_total{status="5xx"} / http_requests_total.
      • Traffic: requests/sec.

✅ Suggested Dev Setup (Practical & Lightweight)

  1. Start with Laravel Telescope → best native tool for queries + request profiling.
  2. Add Clockwork or Debugbar → for real-time in-browser visibility.
  3. If you want structured SLI metrics → add Laravel Prometheus Exporter and run Prometheus + Grafana in Docker.
  4. 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

SettingWhat it doesStarting point (single DB server)Notes
innodb_buffer_pool_sizeMain data+index cache60–70% of RAM (DB-only host)Largest lever for CPU (less I/O).
innodb_buffer_pool_instancesConcurrency in buffer pool1 per ~8–16GB (e.g., 2 for 16GB)Don’t overdo; 1–8 is typical.
innodb_log_file_sizeRedo log size1–4GB total (e.g., 2×1GB)Bigger = fewer flushes; faster writes.
innodb_log_buffer_sizeBuffer for redo before flush64–256MBHelps heavy write bursts.
innodb_flush_log_at_trx_commitDurability vs speed1 (full ACID) or 2 (faster dev)2 reduces fsyncs (OK in dev).
innodb_flush_methodFlush modeO_DIRECT (Linux)Helps avoid double buffering.
innodb_file_per_tableTablespacesONDefault; good for space and manageability.
innodb_flush_neighborsSSD optimization0 (on SSD/NVMe)Reduces extra flush work.

B) Concurrency & CPU

SettingWhat it doesStarting pointNotes
MariaDB thread_pool=ONThread pool (caps active threads)ONGreat at preventing CPU thrash (MariaDB only).
innodb_thread_concurrencyInnoDB internal concurrency0 (auto)Let InnoDB self-tune.
table_open_cacheOpen tables cache2000–4000Raise if “Opened_tables” increases quickly.
table_definition_cacheCached table defs2000Helps many tables/schemas.
open_files_limitProcess file limit>= 65535Aligns with table cache.
skip-name-resolveAvoid DNS on connectEnablePrevents connect latency spikes.

C) Per-connection memory (prevent RAM blow-ups)

These allocate per connection. Keep them modest and keep max_connections realistic.

SettingPurposeStarting pointWarning
max_connectionsHard cap on sessions150–300Each conn can allocate MBs → memory spikes.
tmp_table_sizeMem temp tables64–128MBPairs with max_heap_table_size.
max_heap_table_sizeIn-RAM temp tables64–128MBDon’t set wildly high.
join_buffer_sizeNo-index joins256KB–1MBPer-join, per-thread; keep small.
sort_buffer_sizeORDER BY sorts512KB–2MBToo big × many connections = OOM.
read_buffer_sizeSeq. scans512KB–1MBKeep conservative.
read_rnd_buffer_sizeRandom reads after sort256KB–1MBKeep conservative.

D) Optimizer & SQL safety

SettingWhat it doesStarting pointNotes
sql_require_primary_key (MySQL 8+)Enforce PKsONVital for InnoDB performance & replication.
optimizer_switchPlan tweaksDefaults are fineFocus on indexes first.
innodb_autoinc_lock_modeAUTO_INCREMENT contention2Better concurrency.

E) I/O & background

SettingWhat it doesStarting pointNotes
innodb_io_capacityFlush/IO pacing200–800 (SATA) / 1000–4000 (NVMe)Match device capability.
innodb_read_io_threadsParallel read threads44–8 typical.
innodb_write_io_threadsParallel write threads44–8 typical.
innodb_adaptive_hash_indexHot-range accelerationON (default)Consider OFF if contention (rare).

F) Logging & instrumentation

SettingPurposeSuggested
slow_query_log=ONCapture slow queriesTurn on in dev and prod.
long_query_time=0.2Slow threshold200ms (dev). 0.5–1s in prod.
log_queries_not_using_indexes=ONFind table scansUse in dev (noisy in prod).
performance_schemaEngine for metricsKeep ON, but avoid enabling every consumer (memory!).

G) Binary logs & timeouts (dev vs prod)

SettingPurposeDevProd
skip-log-bin or log_binBinary loggingDisable if no replicasEnable (HA/backups)
sync_binlogCrash safety for binlog01 (strong durability)
wait_timeoutIdle conn close60–300s300–600s
interactive_timeoutIdle interactive300–600s600–1800s

H) MariaDB specifics (if you’re on MariaDB)

SettingWhyValue
thread_pool=ONAvoid CPU storms under loadON
Query CacheCauses contentionOFF (remove/disable)
aria_pagecache_buffer_sizeIf using Aria tmp tablesKeep 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 push max_connections beyond 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_cache if Opened_tables grows; reduce per-connection buffers if memory spikes; if CPU high with many threads, MariaDB thread_pool=ON (or reduce max_connections).

Safe rollout order

  1. Turn on slow log and fix top queries/indexes.
  2. Set buffer pool (and redo log) to match RAM.
  3. Cap max_connections and shrink per-connection buffers.
  4. Enable skip-name-resolve, tune table caches.
  5. Consider thread pool (MariaDB) and I/O capacity.
  6. Re-test; iterate.

Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x