惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Full Disclosure
WordPress大学
WordPress大学
小众软件
小众软件
Cloudbric
Cloudbric
AWS News Blog
AWS News Blog
腾讯CDC
量子位
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
Scott Helme
Scott Helme
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Hacker News
The Hacker News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
Jina AI
Jina AI
Attack and Defense Labs
Attack and Defense Labs
S
SegmentFault 最新的问题
Simon Willison's Weblog
Simon Willison's Weblog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
Google Online Security Blog
Google Online Security Blog
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
罗磊的独立博客
L
LINUX DO - 最新话题
博客园 - Franky
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
The Last Watchdog
The Last Watchdog
J
Java Code Geeks
AI
AI
C
Cisco Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
Help Net Security
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
I
Intezer
S
Securelist

Anže's Blog

The 15-Year-Old iptables Rule That Broke My DNS Fedidevs 9h Outage Postmortem Letting Claude Upgrade My Raspberry Pi Agents Day Lisbon DjangoCon Europe 2026 How to Safely Update Your Dependencies Speeding Up Django Startup Times with Lazy Imports Typing Your Django Project in 2026 Claude Fixes User Bug Jekyll to Hugo Migration Advent of Code 2025 🎄 Django bulk_update Memory Issue Disable Network Requests When Running Pytest Disable Runserver Warning in Django 5.2 Autogenerating og:images with Jekyll Power Outages and Gunicorn PID Files UV with Django Go-like Error Handling Makes No Sense in JavaScript or Python Packages Do Not Match the Hashes Pip Error Gotchas with SQLite in Production Fedidevs Dev Update #2 Django SQLite Production Config Django Streaming HTTP Responses Deploying a Django Project to My Raspberry Pi (Video) Thoughts on Code Reviews Django SQLite Benchmark Django, SQLite, and the Database Is Locked Error No Downtime Deployments with Gunicorn SQLite Write-Ahead Logging Writing a Pytest Plugin Fedidevs Dev Update #1 Django-TUI: A Text User Interface for Django Commands Automate Hatch Publish with GitHub Actions Words TUI: App for Daily Writing Textual App Auto Reload RDS Blue/Green Deployments Fly.io Certificate Renewal Using Testing Library with Selenium in Python The Fastest Way to Build a Read-only JSON API import __hello__ Enum with `str` or `int` Mixin Breaking Change in Python 3.11 Your Code Doesn't Have to Be Perfect Fixing _SixMetaPathImporter.find_spec() Not Found Warnings in Python 3.10 Upgrading Django App to Python 3.10 Integer Overflow Error in a Python Application Python Dependency Management MySQL Performance Degradation in Django 3.1 New Features in Python 3.8 and 3.9 The Code Review Batch Size The Code Review Bottleneck
Migrating Gunicorn to Granian
Anže Pečar · 2025-09-27 · via Anže's Blog

I migrated one of my Django apps from Gunicorn to Granian yesterday. Here is how the migration went and some of my thoughts on Granian and Gunicorn.

Migration

This is the second time I attempted to try out Granian. The first time I got blocked because Granian didn’t support unix sockets. I run several Django apps on the same host behind Nginx, and I’m using Unix sockets for communication between Nginx and Gunicorn. I could have switched to using ports, but I didn’t want to mess with Nginx for this experiment.

Since then, Granian has added support for Unix sockets, so this is no longer a blocker. In fact, all the Gunicorn settings that I was using had their equivalent in Granian, including the ability to set the process name (again, extremely useful when running multiple Django Apps on a single host).

This was my existing gunicorn.conf.py file:

proc_name = "fedidevs"
bind = "unix:fedidevs.sock"
workers = 4
threads = 4

I started the Gunicorn process with:

Since Granian doesn’t have a dedicated setting file it’s now all a single command:

granian \
    --interface wsgi fedidevs.wsgi:application \
    --process-name fedidevs \
    --uds fedidevs.sock \
    --workers 4 \
    --blocking-threads 4

Performance

Granian is written in Rust, so it should be faster than Gunicorn, which is in pure Python. Granian’s benchmark says that Granian should be about 10ms faster than Gunicorn Gthread for WSGI.

Chart of response times before and after the upgrade. No visible difference.

However, as we can see from the response times on my app above, there appears to be no change in response times. You can’t even tell where on the chart I switched from Gunicorn to Granian.

This is probably because Gunicorn (and now Granian) was already running behind Nginx, so all the request scheduling was already done by the efficient Nginx C code before it reached Gunicorn’s Python code.

Docs

Grenian doesn’t have a dedicated docs page like Gunicorn, but the Readme is comprehensive. I enjoyed reading the Workers and threads section, and I feel it provides better guidance than Gunicorn’s How Many Workers? and How Many Threads? sections, which feel a bit dated.

Request timeouts

I was hoping that Granian’s --blocking-threads-idle-timeout would kill requests that have been running for too long. Unfortunately, it seems to work like Gunicorn’s --timeout parameter and only kills workers that have stopped responding.

Not useful if you end up with a bunch of idle requests because a third-party service stopped responding. The only solution for this is to add timeouts to all I/O operations of your application rigorously.

Fin

If you enjoy trying out new things, do give Granian a go; it’s a wonderful project. Your existing projects can continue using Gunicorn. You probably won’t see a big difference after the migration.