Skip to content

Instantly share code, notes, and snippets.

Jordan Eremieff erm

Block or report user

Report or block erm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@erm
erm / asgi.py
Last active Jul 23, 2019
Testing Datasette with Mangum
View asgi.py
from mangum import Mangum
from datasette.app import Datasette
import boto3
DB_NAME = "mydb.db"
DB_PATH = f"/tmp/{DB_NAME}"
BUCKET_NAME = "mybucket"
View gist:975e9a8dda60d94823dc5f8a8d354b57

Still not running under ideal test conditions, but here is a more fair comparison (using meinheld for WSGI):

uvicorn asgiproj.asgi:application -w2

[erm@fezzan django-async]$ wrk -d20s -t10 -c200 http://127.0.0.1:8000/asgi/
Running 20s test @ http://127.0.0.1:8000/asgi/
  10 threads and 200 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency    15.10ms    9.77ms 194.12ms   89.38%
@erm
erm / gist:130ff4fa7b4d428f4e98057858795aba
Last active Apr 1, 2020
Initial benchmark comparisons of ASGI (uvicorn) and WSGI (gunicorn)
View gist:130ff4fa7b4d428f4e98057858795aba

These benchmarks and the fork used are out-of-date, look into more recent versions of Django and newer benchmarks

Please note:

A more fair comparison is here with gunicorn using the meinheld worker https://gist.github.com/erm/975e9a8dda60d94823dc5f8a8d354b57.

Also, these benchmarks were run against an experimental fork of Django and the testing conditions are not ideal. They aren't intended to be a conclusive measure of the performance differences between ASGI/WSGI. Proper benchmarks to come later.

Test project:

View home.py
@app.route('/')
def home(scope):
return HttpResponse(scope, body=HTML_BODY, headers=[[b'content-type', b'text/html']])
@erm
erm / blackboard.css
Created Feb 23, 2017
port of textmate's blackboard theme
View blackboard.css
/* Port of TextMate's Blackboard theme */
.cm-s-blackboard { background: #0C1021; color: #F8F8F8; }
.cm-s-blackboard .CodeMirror-selected { background: #253B76 !important; }
.cm-s-blackboard .CodeMirror-gutter { background: #0C1021; border-right: 0; }
.cm-s-blackboard .CodeMirror-gutter-text { color: #888; }
.cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7 !important; }
.cm-s-blackboard .cm-keyword { color: #FBDE2D; }
.cm-s-blackboard .cm-atom { color: #D8FA3C; }
@erm
erm / GAME_MASTER_v0_1.protobuf
Created Jul 17, 2016 — forked from anonymous/GAME_MASTER_v0_1.protobuf
Pokemon Go decoded GAME_MASTER protobuf file v0.1
View GAME_MASTER_v0_1.protobuf
Result: 1
Items {
TemplateId: "BADGE_BATTLE_ATTACK_WON"
Badge {
BadgeType: BADGE_BATTLE_ATTACK_WON
BadgeRanks: 4
Targets: "\nd\350\007"
}
}
Items {
@erm
erm / GAME_MASTER_v0_1.protobuf
Created Jul 17, 2016 — forked from anonymous/GAME_MASTER_v0_1.protobuf
Pokemon Go decoded GAME_MASTER protobuf file v0.1
View GAME_MASTER_v0_1.protobuf
Result: 1
Items {
TemplateId: "BADGE_BATTLE_ATTACK_WON"
Badge {
BadgeType: BADGE_BATTLE_ATTACK_WON
BadgeRanks: 4
Targets: "\nd\350\007"
}
}
Items {
@erm
erm / example_django_app
Created Dec 12, 2015
Example nginx config for uwsgi
View example_django_app
server {
listen 80;
server_name <YOUR APPS HOSTNAME>;
set $static_home /home/<YOUR USERNAME>/apps/example_django_app;
location /static/ {
alias $static_home/static/;
access_log off;
expires max;
}
@erm
erm / example_django_app.ini
Created Dec 12, 2015
Example uwsgi config
View example_django_app.ini
[uwsgi]
master = true
plugin = python
socket = /tmp/uwsgi-%n.sock
processes = 1
max-requests = 10000
harakiri = 60
reaper = true
chmod-socket = 666
chdir = /home/<YOUR USERNAME>/apps/%n
@erm
erm / helloworld.py
Created Dec 21, 2014
helloworld.py
View helloworld.py
import tweepy
CONSUMER_KEY = '<replace me!>'
CONSUMER_SECRET = '<replace me!>'
ACCESS_TOKEN = '<replace me!>'
ACCESS_TOKEN_SECRET = '<replace me!>'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
You can’t perform that action at this time.