Skip to content

Instantly share code, notes, and snippets.

View BrahimAfa's full-sized avatar
🐢
Creating bugs

Brahim Afassy BrahimAfa

🐢
Creating bugs
View GitHub Profile

Nginx Performance Tuning: Understanding ulimit, File Descriptors, and Kernel Limits

A Step-by-Step Guide with Practical Examples


1. Introduction

Web servers like Nginx handle thousands of concurrent connections. To avoid bottlenecks, you must understand:

  • File Descriptors (FDs): How the kernel tracks open files/sockets.
  • Resource Limits (ulimit/rlimit): How the kernel enforces per-process limits.
  • Nginx Configuration: How to optimize settings like worker_rlimit_nofile and worker_connections.
@BrahimAfa
BrahimAfa / shortcuts.md
Created February 1, 2025 17:59 — forked from memphys/shortcuts.md
Bash Shortcuts For Maximum Productivity

source: http://www.skorks.com/2009/09/bash-shortcuts-for-maximum-productivity/

Command Editing Shortcuts

  • Ctrl + a – go to the start of the command line
  • Ctrl + e – go to the end of the command line
  • Ctrl + k – delete from cursor to the end of the command line
  • Ctrl + u – delete from cursor to the start of the command line
  • Ctrl + w – delete from cursor to start of word (i.e. delete backwards one word)
  • Ctrl + y – paste word or text that was cut using one of the deletion shortcuts (such as the one above) after the cursor
@BrahimAfa
BrahimAfa / git_submodules.md
Created April 17, 2023 12:46 — forked from gitaarik/git_submodules.md
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of advantages of using submodules:

  • You can separate the code into different repositories.
@BrahimAfa
BrahimAfa / on-merge-deploy-to-do.md
Created December 21, 2022 19:16 — forked from danieltorscho/on-merge-deploy-to-do.md
GitHub Action deploy nodejs to DigitalOcean Droplet

Github deployment

Requirements:

  • DigitalOcean Droplet (Ubuntu 20.04+) should be created
  • Github repository

Prepare DO Droplet Server:

  • ssh root@DROPLET_IP
  • sudo vi /etc/ssh/sshd_config
  • change PasswordAuthentication from no to yes
[supervisord]
nodaemon=true
loglevel=debug
[program:amon]
command=gunicorn -c gunicorn.conf.py wsgi
directory=/amon
autostart=true
autorestart=true
redirect_stderr=true
@BrahimAfa
BrahimAfa / install_ngrok.md
Created March 1, 2022 21:40 — forked from SalahHamza/install_ngrok.md
How to install ngrok on linux subsystem for windows
@BrahimAfa
BrahimAfa / sane-caching.nginx.conf
Created February 3, 2022 18:09 — forked from philipstanislaus/sane-caching.nginx.conf
Sample Nginx config with sane caching settings for modern web development
# Sample Nginx config with sane caching settings for modern web development
#
# Motivation:
# Modern web development often happens with developer tools open, e. g. the Chrome Dev Tools.
# These tools automatically deactivate all sorts of caching for you, so you always have a fresh
# and juicy version of your assets available.
# At some point, however, you want to show your work to testers, your boss or your client.
# After you implemented and deployed their feedback, they reload the testing page – and report
# the exact same issues as before! What happened? Of course, they did not have developer tools
# open, and of course, they did not empty their caches before navigating to your site.
@BrahimAfa
BrahimAfa / reset.md
Created January 28, 2022 11:04 — forked from hitautodestruct/reset.md
Reset root password on scaleway.com
@BrahimAfa
BrahimAfa / nginx-tuning.md
Created January 10, 2022 01:28 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@BrahimAfa
BrahimAfa / README.md
Created November 9, 2021 21:19 — forked from mrbar42/README.md
Secured HLS setup with Nginx as media server

Secured HLS setup with Nginx as media server

This example is part of this article.

This is an example for an HLS delivery with basic security. Nginx compiled with nginx-rtmp-module & secure-link is used as media server. Features:

  • Domain filtering
  • Referrer filtering
  • Embed buster