Performance: Why background processing matters
HIGH IMPACT
Background processing affects how fast the main web page loads and how responsive the server feels to users.
from flask import Flask, request from threading import Thread app = Flask(__name__) def background_task(): do_heavy_task() @app.route('/process') def process(): Thread(target=background_task).start() return 'Task started'
from flask import Flask, request app = Flask(__name__) @app.route('/process') def process(): # Long task runs here do_heavy_task() return 'Done'
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Synchronous long task in request | Minimal | Minimal | Delayed due to slow response | [X] Bad |
| Background task with immediate response | Minimal | Minimal | Fast initial paint | [OK] Good |