Skip to content

Instantly share code, notes, and snippets.

Optimizing Django and Celery for Handling Many Concurrent Requests

Handling a high volume of concurrent requests in a Django application with Celery for background tasks can be challenging. This guide will walk you through the necessary steps to optimize your setup for better performance and scalability.

Default Setup with Gunicorn and Celery

By default, Gunicorn with Django and Celery uses synchronous workers to handle web requests and background tasks. This means:

  • Gunicorn: Uses sync workers which can handle one request at a time per worker.
  • Celery: Processes tasks synchronously within each worker.
@Fanman03
Fanman03 / UAP-Guide.md
Last active April 28, 2025 11:58
UniFi AP Buyers Guide

UniFi AP Buyers Guide

(updated March 2025)

The APs in this list are ordered from highest to lowest performance. However, unless you have an insane amount of devices you likely do NOT need to buy the most expensive, highest performance AP. You can also check Ebay for deals, especially on older equipment. In terms of best price-to-performance, the U6 Pro/Mesh/InWall series is the sweet spot in my opinion and is the best choice for most deployments.

All APs in this list support both wired backhaul and mesh modes. However, wired connections are strongly recommended for better performance and reliability.

Number of spatial streams are listed in order of 2.4GHz, 5GHz, 6GHz.

Good Choices:

@geerlingguy
geerlingguy / cache-purge.yml
Last active November 30, 2022 19:26
Cache purge script to clear Nginx + Cloudflare cache for a given set of URLs.
---
- hosts: webserver
become: true
gather_facts: false
vars:
# API token should be created with cache_purge permissions.
cloudflare_purge_zone: [zone id from cloudflare]
cloudflare_purge_token: "{{ lookup('env','CLOUDFLARE_PURGE_TOKEN') }}"
cloudflare_purge_body:
@cmer
cmer / whitelist_telnyx_ip.sh
Created November 13, 2021 14:13
Whitelist IP with Telnyx (cronjob)
#!/bin/bash
# This simple bash script will auto-update Telnyx with the network's public IP address when it changes.
# Simply add a cron job to call it every minute or so.
#
# requirements: apt install curl dnsutils jq
#
API_KEY="{{ API_KEY_HERE }}"
@alyssacohen
alyssacohen / lapdogbackup.md
Last active October 2, 2022 02:35
My laptop backup with restic

My Laptop Backup with restic

Some notes about setting up automatic backup on IBM Cloud Object Storage.

Inspired by an article about making free backups to the cloud and this one about automating the process with systemd, I decided to set up automatic backup over the internet of my mule laptop "lapdog". It's an Arch Linux powered machine I mostly use to kill time, so it's not a big deal if for some reason I screw things up. Something went wrong when I followed that guide, so I decided to retrace all the steps following restic and aws documentation instead of those articles. And here is my version of the guide (hope it helps someone) IBM COS basically let you create an Amazon S3 bucket with up to 25GB of cloud space to upload your backups for free! 😁 Too small for a full system backup, but enough fo

@herberthamaral
herberthamaral / nats_to_sse.py
Last active January 3, 2024 14:51
Listen to a nats topic and write to a HTTP client listening via server-sent-events
import asyncio
from typing import AsyncGenerator, Dict
from fastapi import FastAPI
from nats.aio.client import Client as NATS
from nats.aio.client import Msg
from starlette.requests import Request
from starlette.responses import StreamingResponse
app = FastAPI()
@brasey
brasey / Configure systemd-resolved to use a specific DNS nameserver for a given domain.md
Created October 25, 2019 14:38
Configure systemd-resolved to use a specific DNS nameserver for a given domain

Configure systemd-resolved to use a specific DNS nameserver for a given domain

Use case

Given

  • I use a VPN to connect to my work network
  • I'm on a Linux computer that uses systemd-resolved
  • I have a work domain called example.com
  • example.com is hosted by both public and private DNS nameservers
@ruanbekker
ruanbekker / traefik_portainer.md
Last active April 23, 2025 17:54
Traefik with SSL + Portainer on Docker Swarm Repro

Traefik and Portainer on Docker Swarm with Letsencrypt

Reproducing a Traefik with SSL and Portainer setup on a 2 Node Docker Swarm

Install Docker:

Install Docker on both nodes with a Bootstrap Script:

$ curl https://gitlab.com/rbekker87/scripts/raw/master/setup-docker-ubuntu.sh | bash
@tuco86
tuco86 / Dockerfile
Last active May 30, 2019 21:05
Build packages as wheels, then install in small container.
FROM python:3.7-slim-stretch AS build
RUN \
apt-get -q update \
&& apt-get -q install -y --no-install-recommends \
build-essential \
libssl-dev \
&& rm -rf /var/lib/apt/lists/* \
&& pip install -U pip