What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
The reliable way to make Flask faster on a Linux VPS is to measure first, then remove the bottleneck you can demonstrate. Record latency percentiles, errors, CPU, memory, disk I/O, and database time for representative endpoints. Replace Flask’s development server with Gunicorn, put Nginx (or another dedicated HTTP server) in front of it, tune workers to the VPS’s measured CPU and memory limits, serve static files at the proxy, cache only results that may be stale, and profile SQLAlchemy queries before rewriting application code.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
There is no universal worker count or guaranteed percentage improvement. The correct configuration depends on request mix, blocking I/O, query behavior, memory per process, and the limits of the particular VPS.
As an Amazon Associate I earn from qualifying purchases.
Recommended Free Tools
Start with a measurable baseline
Optimization without a baseline turns configuration changes into guesswork. Before changing Flask, Gunicorn, Nginx, or the database, capture the behavior of the application as it is now. Use the same representative request mix after each major change so that an apparent improvement is not simply a quieter test period.
Record the metrics that explain user-visible speed
- Latency: collect average latency when useful, but prioritize p50 (typical), p95, and p99 (tail) latency. A fast median with a slow tail often indicates blocking I/O, overloaded workers, or a database queue.
- Traffic: record requests per second or requests per minute by endpoint, including bursts rather than only daily averages.
- Errors: track HTTP status classes, application exceptions, worker timeouts, and connection failures alongside latency.
- CPU: note total utilization, per-core saturation, and whether runnable work is waiting for CPU.
- Memory: watch resident memory per Gunicorn worker, total usage, swap activity, and out-of-memory events.
- Disk I/O: measure read/write latency and queueing, especially when the VPS also hosts a database, uploads, logs, or an embedded file store.
- Database timing: separate time spent waiting for SQL execution, fetching rows, and constructing ORM objects.
A simple request-timing probe can establish a repeatable starting point for one endpoint:
#1 Best Overall
- BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
- EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
- COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
- LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
- WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
curl -s -o /dev/null -w 'status=%{http_code} total=%{time_total}s connect=%{time_connect}s starttransfer=%{time_starttransfer}s
' https://app.example.com/health
Repeat the probe enough times to expose variability, and test real dynamic endpoints as well as a health route. A health route that does no database work cannot represent a page whose response depends on several queries.
Interpret the first result before tuning
High latency with idle CPU often points toward database waits, an upstream API, disk I/O, or lock contention. High CPU with short database timings points toward Python code, serialization, template rendering, or too many workers competing for limited cores. Memory pressure and swapping can make every request slower even when average CPU appears moderate. A proxy cannot repair an inefficient query, and adding workers cannot make a single serialized operation execute faster.
Move off Flask’s development server
Flask’s built-in development server, debugger, and reloader are for local development. Flask documentation explicitly warns that the development server is not designed to be particularly secure, stable, or efficient for production. Run the application through a production WSGI server instead.
Run a minimal Gunicorn deployment
Gunicorn loads a WSGI application using a target such as module:app. If the application uses an app factory, a callable form such as module:create_app() can be used. Bind Gunicorn to a private loopback address when Nginx is the public entry point:
python -m gunicorn --workers 4 --bind 127.0.0.1:8000 wsgi:app
Replace wsgi:app with the import path used by your project. The command is an example, not a promise that four workers is optimal. Confirm that the process can import configuration, reach its database, and write only to directories intended for runtime data.
Rank #2
- WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
- AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
- PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
- ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
- COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed
Make the service reproducible
Use a process supervisor such as systemd so the service starts after boot, restarts after an abnormal exit, and runs with a predictable working directory and virtual environment. One possible unit is:
[Unit]
Description=Flask application served by Gunicorn
After=network.target
[Service]
User=flaskapp
Group=flaskapp
WorkingDirectory=/srv/flaskapp/current
EnvironmentFile=/etc/flaskapp/flaskapp.env
ExecStart=/srv/flaskapp/venv/bin/gunicorn --workers 4 --bind 127.0.0.1:8000 wsgi:app
Restart=on-failure
[Install]
WantedBy=multi-user.target
Store secrets in the environment file or a dedicated secret-management mechanism rather than in the unit or source tree. After changing the unit, reload systemd, restart the service, and inspect its logs. Keep Flask, Gunicorn, Nginx, SQLAlchemy, and related extension versions pinned and review compatibility when upgrading; defaults and supported options change over time.
Tune Gunicorn workers from measurements
Gunicorn’s -w option controls the number of worker processes. Flask’s deployment guidance presents four workers as an example and mentions CPU multiplied by two as a possible starting heuristic. Treat that number as the first experiment, not a universal formula: every worker consumes memory, and workload behavior differs.
Use a conservative tuning loop
- Start with a small worker count that leaves memory headroom. Four workers is a documented example, while CPU multiplied by two is only a starting heuristic.
- Generate the same representative request mix used for the baseline.
- Compare p95 and p99 latency, throughput, errors, CPU saturation, resident memory, and swap activity.
- Increase workers only while they improve useful concurrency without exhausting memory or causing CPU contention.
- If additional workers stop improving latency, investigate the database, blocking calls, lock contention, or a single-threaded bottleneck instead of continuing to increase the count.
A worker process can hold application state, imported modules, connection pools, and caches. Multiplying the number of processes therefore multiplies much of the memory footprint. A VPS that appears to have spare CPU can still fail under load if workers push it into swapping.
Choose a worker class that matches the workload
| Choice | When it fits | Risks and checks |
|---|---|---|
| Synchronous worker (Gunicorn default) | Ordinary request/response endpoints whose work completes promptly. | Each worker handles one request at a time. Slow clients or blocking upstream calls can occupy workers; use proxy buffering and measure queueing. |
| Asynchronous worker such as gevent | Many concurrent, long-running connections where cooperative I/O is appropriate. | Validate library compatibility, monkey-patching behavior, blocking calls, and tail latency. It is not an automatic solution for CPU-bound Python code. |
Do not switch worker classes solely because an application feels slow. Compare concurrency, blocking I/O, memory per worker, tail latency, operational complexity, and compatibility with every database and networking library in use.
Rank #3
- Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
- Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
- Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
- ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
- Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)
Put Nginx in front of Gunicorn
Gunicorn’s deployment guidance strongly recommends running behind a proxy. Nginx accepts public HTTP connections, handles static assets and buffering, and forwards dynamic requests to Gunicorn. This keeps slow clients from occupying synchronous Python workers and gives the public-facing server responsibility for connection management.
Use a private upstream
When Nginx is the intended public entry point, do not leave a separately reachable Gunicorn bind on a public interface. Bind Gunicorn to loopback or a protected Unix socket and allow only Nginx to reach it. A minimal Nginx server block using loopback is:
server {
listen 80;
server_name app.example.com;
location /static/ {
alias /srv/flaskapp/current/static/;
expires 1h;
add_header Cache-Control "public";
}
location / {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering on;
}
}
Adjust paths, hostnames, and security policy to your deployment. The key performance properties are that Nginx serves public connections and static files, forwards the original request context, and buffers responses where appropriate. Gunicorn specifically warns that synchronous workers need proxy buffering to protect them from slow clients.
Understand what the proxy does not fix
Nginx can reduce Python work per request and absorb connection-management overhead, but it cannot make a slow SQL statement fast or reduce CPU spent in application code. If proxy timing is low while upstream timing is high, profile Flask and its dependencies. If upstream responses are quick but clients receive data slowly, inspect network conditions, response size, compression policy, and buffering.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Serve static assets outside Flask
Configure Nginx to serve versioned CSS, JavaScript, images, fonts, and downloads that do not require application logic. Each static request handled by Nginx leaves a Gunicorn worker available for dynamic work.
Rank #4
- Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
- Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
- 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
- Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
- USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC
Use cacheable asset names
Give assets versioned or content-hashed names when your build process supports it. Then Nginx can send cache headers without risking that a browser uses an old file after a deployment. If filenames are not versioned, use a shorter expiration period and plan how clients receive updates.
- Keep the static directory readable by the Nginx worker.
- Keep private uploads outside a publicly aliased directory unless every file is intended to be public.
- Measure response size and transfer time for large assets; moving them out of Flask does not remove network bandwidth limits.
- Ensure the application still generates correct URLs when it is behind a proxy and served under the expected scheme and host.
Add caching only where stale data is safe
Flask itself does not provide caching. Flask-Caching supplies configurable cache backends for results that can be reused. Caching is appropriate when a calculation is expensive and a result that is, for example, five minutes old is acceptable.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Define cache semantics before adding a decorator
- Identify the expensive, repeatable operation and measure its current cost.
- Decide exactly which inputs determine the result: URL parameters, request headers, locale, user identity, permissions, and feature flags.
- Set an expiration that reflects business tolerance for stale data.
- Define invalidation events for writes, deployments, permission changes, and deleted records.
- Measure hit rate, miss latency, cache size, eviction behavior, and the effect of stale responses.
A simple process-local configuration can illustrate the API:
from flask import Flask
from flask_caching import Cache
app = Flask(__name__)
cache = Cache(config={
"CACHE_TYPE": "SimpleCache",
"CACHE_DEFAULT_TIMEOUT": 300,
})
cache.init_app(app)
@app.get("/catalog")
@cache.cached(timeout=300)
def catalog():
return build_catalog_response()
A process-local cache is separate in each Gunicorn worker. That can be acceptable for a small deployment, but it means one worker’s cached value is not automatically visible to another. For multiple workers or multiple VPS instances, choose a shared backend whose latency, persistence expectations, serialization, eviction policy, and failure behavior fit the application.
Avoid unsafe cache keys
Never cache a personalized or security-sensitive response under a key that can be reused by another user. Include every response-changing input in the key, or exclude the endpoint from caching. Also account for authorization changes: a cached response can outlive the permission decision that produced it.
Best Value
- Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
- Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
- Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
- Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
- Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.
Find database bottlenecks with SQLAlchemy profiling
When database time dominates a request, changing Flask routing or adding Gunicorn workers will not address the cause. SQLAlchemy’s performance guidance starts with profiling query execution, code paths, result fetching, and SQL compilation caching.
Free tools Windows power users keep installed
One-click scans. No signup required.
Separate the stages of database work
- Execution: time spent by the database planning and running SQL. Investigate query plans, locks, missing or ineffective indexes, joins, and transaction scope only after measuring.
- Fetching: time transferring rows from the database. Large result sets, excessive columns, and network latency appear here.
- ORM construction: time creating Python objects and related collections. N-plus-one loading and unexpectedly broad relationship loads can be expensive even when SQL execution is quick.
- Compilation: time SQLAlchemy spends generating SQL. Check whether SQL compilation caching is working; disabled caching can make ORM performance significantly poorer in some cases.
Turn on useful diagnostics temporarily
Enable SQL logging in a controlled environment or for a limited period, correlate each statement with a request identifier, and record execution and fetch durations. Profiling should include the surrounding Python code so that a fast query followed by expensive serialization is not misdiagnosed as a database problem. Remove verbose logging or reduce its level after diagnosis; logging every statement can add I/O and generate a new bottleneck.
Do not add indexes, rewrite joins, or replace ORM code solely because a query looks complicated. First identify whether the time is in execution, transfer, object construction, or compilation, then change the component responsible and remeasure the same endpoint.
Match the VPS to the bottleneck
VPS plans differ in CPU share, memory headroom, storage I/O, network limits, and whether the database runs on the same machine. There is no cited universal numeric VPS size that wins for every Flask deployment.
| Observed constraint | What to inspect | Likely action |
|---|---|---|
| CPU remains saturated while database time is low | Python hotspots, template rendering, serialization, compression, and worker contention. | Profile code, reduce repeated work, serve static files at Nginx, and test a carefully chosen worker count. |
| Memory pressure or swap activity | Resident memory per worker, application caches, large responses, and database memory on the same VPS. | Reduce worker count or per-process memory, move or resize services, and remove unnecessary in-process caches. |
| High disk latency | Database files, logs, uploads, temporary files, and backup jobs. | Reduce synchronous writes, rotate logs, separate heavy storage work, or choose storage with better I/O characteristics. |
| Database timing dominates | Execution, fetching, ORM construction, transaction duration, and connection-pool waits. | Profile SQLAlchemy and the database path before changing Flask or Gunicorn. |
| Network or connection limits | Response sizes, concurrent clients, proxy queues, and upstream connection counts. | Use Nginx for connection handling, reduce unnecessary payloads, and verify the VPS network allowance. |
Use a repeatable optimization workflow
- Capture a baseline. Record p50, p95, and p99 latency where available, request volume, errors, CPU, memory, disk I/O, and database timings for representative endpoints.
- Deploy a production WSGI server. Replace the development server with Gunicorn or another dedicated WSGI server and verify imports, environment variables, logs, and restart behavior.
- Choose an initial worker count. Use a conservative value such as the documented four-worker example or a CPU-multiplied starting point, then measure memory and tail latency.
- Add the reverse proxy. Put Nginx in front, bind Gunicorn privately, enable suitable buffering, and verify forwarded host, protocol, and client-address headers.
- Move static traffic out of Flask. Serve versioned assets directly from Nginx with cache headers that match the naming strategy.
- Profile the slowest dynamic endpoint. Determine whether time is spent in Python, an upstream service, proxy queues, SQL execution, row fetching, ORM construction, or serialization.
- Cache safe repeatable work. Set explicit expiration and invalidation rules, protect personalized responses, and monitor hit rate and stale-data effects.
- Change one material factor at a time. Repeat the same request mix and retain the measurements so regressions are visible.
Troubleshoot common symptoms
Requests time out after adding load
- Check whether all synchronous workers are occupied by slow database calls or upstream requests.
- Confirm Nginx is buffering slow clients instead of allowing them to hold Gunicorn workers.
- Inspect database connection-pool waits and lock duration.
- Increase worker count only if CPU and memory measurements show capacity; otherwise, remove the blocking work.
Latency rises while CPU is low
- Measure database execution and fetch time separately from Python time.
- Check for network calls, DNS delays, storage latency, and lock contention.
- Look for an Nginx or upstream queue rather than assuming Flask is the bottleneck.
Latency rises and memory is exhausted
- Compare resident memory across workers and after repeated requests.
- Check whether an in-process cache or retained object grows without bound.
- Reduce workers temporarily to stop swapping, then profile the application’s per-request and per-process allocation.
Static files are unexpectedly slow
- Verify that the request matches Nginx’s static location and is not falling through to Flask.
- Check filesystem permissions, asset size, cache headers, and network transfer time.
- Confirm that the proxy is not forwarding private files unintentionally.
Performance changes after an upgrade
Record the exact Flask, Gunicorn, Nginx, SQLAlchemy, Python, and extension versions. Compare configuration defaults, worker behavior, SQL compilation caching, and logging levels between the working and slower deployments. Roll back the smallest changed component only after preserving the measurements that demonstrate the regression.
Quick Recap
Production checklist
- Development server and debugger are not exposed to the internet.
- Gunicorn or another production WSGI server starts through a supervisor and uses a pinned virtual environment.
- Gunicorn listens only on a private address or protected socket when Nginx is public.
- Nginx handles public connections, forwards the correct host and protocol, and buffers responses for synchronous workers.
- Static assets are served outside Flask with cache headers appropriate to their naming scheme.
- Worker count has been tested against CPU, memory, error rate, p95, and p99 latency.
- Cache keys, expiration, invalidation, personalization, and failure behavior are documented.
- SQLAlchemy diagnostics distinguish execution, fetching, ORM construction, and SQL compilation.
- Database, disk, memory, and network limits are monitored on the VPS rather than inferred from application latency alone.
- Every optimization is rechecked with the same representative request mix, and no fixed speedup is assumed without measurements from this deployment.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




