Skip to content

Instantly share code, notes, and snippets.

View guptarohit's full-sized avatar
🧘‍♂️
Focusing 🔁 1.01³⁶⁵

Rohit Gupta guptarohit

🧘‍♂️
Focusing 🔁 1.01³⁶⁵
View GitHub Profile
@guptarohit
guptarohit / keybase.md
Created July 4, 2021 20:10
keybase.md

Keybase proof

I hereby claim:

  • I am guptarohit on github.
  • I am rohitgupta (https://keybase.io/rohitgupta) on keybase.
  • I have a public key ASD2LVHZkTKk-uB6ZWVpsMQU-ALMX8UUZ4ef-4q6hM5YrAo

To claim this, I am signing this object:

@guptarohit
guptarohit / .pre-commit-config.yaml
Created November 14, 2019 11:07
pre-commit hooks pipeline with isort, black and flake8
repos:
- repo: https://github.com/asottile/seed-isort-config
rev: v1.9.3
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.21
hooks:
- id: isort
- repo: https://github.com/ambv/black
@guptarohit
guptarohit / .isort.cfg
Created November 15, 2019 12:47
isort hook configuration
[settings]
line_length = 88
multi_line_output = 3
include_trailing_comma = True
known_third_party = celery,django,environ,pyquery,pytz,redis,requests,rest_framework
@guptarohit
guptarohit / pyproject.toml
Created November 15, 2019 12:49
black hook configuration
[tool.black]
line-length = 88
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
@guptarohit
guptarohit / .flake8
Created November 15, 2019 12:50
flake8 hook configurations
[flake8]
max-line-length = 88
max-complexity = 18
select = B,C,E,F,W,T4,B9
ignore = E203, E266, E501, W503, F403, F401
@guptarohit
guptarohit / pyproject.toml
Created November 14, 2019 11:00
pre-commit hooks configuration
[tool.black]
line-length = 88
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
location / {
...
access_log /var/log/nginx/fast_api.log combined buffer=256k flush=10s;
error_log /var/log/nginx/fast_api.err.log;
}
proxy_cache_path /data/nginx/cache keys_zone=my_zone:10m inactive=1d;
server {
...
location /api-endpoint/ {
proxy_cache my_zone;
proxy_cache_key "$host$request_uri$http_authorization";
proxy_cache_valid 404, 302 1m;
proxy_cache_valid 200 1d;
add_header X-Cache-Status $upstream_cache_status;
}
worker_processes auto;
#or should be equal to the CPU core, you can use `grep processor /proc/cpuinfo | wc -l` to find; auto does it implicitly.
worker_connections 1024;
# default is 768; find optimum value for your server by `ulimit -n`
access_log off;
# to boost I/O on HDD we can disable access logs
# this prevent nginx from logging every action in a log file named `access.log`.
Running 20s test @ http://api.endpoint/resource
20 threads and 200 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 192.48ms 274.78ms 1.97s 87.18%
Req/Sec 85.57 29.20 202.00 72.83%
33329 requests in 20.03s, 29.59MB read
Socket errors: connect 0, read 0, write 0, timeout 85
Requests/sec: 1663.71
Transfer/sec: 1.48MB