Skip to content

Instantly share code, notes, and snippets.

@nkokkos
nkokkos / nginx-tuning.md
Created September 12, 2025 07:52 — 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.

# RingBuffer class:
# https://github.com/celluloid/celluloid/blob/master/lib/celluloid/logging/ring_buffer.rb
# added the moving average method
class RingBuffer
attr_reader :buffer
def initialize(size)
@size = size
require './ring_buffer.rb'
iterations = 1000
RING_SIZE = 25
ring = RingBuffer.new(RING_SIZE)
iterations.times do |i|
time_start = Time.now
400000.times do |t|
@nkokkos
nkokkos / filter_Select_listbox.html
Last active May 23, 2021 17:58
Filter Select List Box with ES6
/* Stolen from here: https://esausilva.com/2017/02/21/filter-select-list-options-typeahead-in-javascript-es6/ */
/* Added document.getElementByID instead of querySelectorAll
<html>
<head>
<style>
div {
width: 280px;
margin: 10 auto;
}
input {
@nkokkos
nkokkos / gist:9495540852395161c58a84916de235b1
Created October 15, 2018 09:47
Break a pdf file to subparts with ghostscript on windows
c:\gswin32c.exe -sDEVICE=pdfwrite \
-dNOPAUSE \
-dBATCH \
-dSAFER \
-dCompatibilityLevel=1.6 \
-dPDFSETTINGS=/prepress
-dEmbedAllFonts=true \
-dSubsetFonts=false \
-dFirstPage=1 -dLastPage=100 \
@nkokkos
nkokkos / gist:9ffddfb1f47e7690c381b429f2925123
Created January 19, 2018 15:14
Rescue Commands in Postgresql
Rescue Commands in Postgresql
#start with:
$sudo su postgres
$psql
#then do :
#show all databases
\dl
var RTCPeerConnection = null;
var getUserMedia = null;
var attachMediaStream = null;
var reattachMediaStream = null;
var webrtcDetectedBrowser = null;
var webrtcDetectedVersion = null;
function trace(text) {
if (text[text.length - 1] === "\n") {
text = text.substring(0, text.length - 1);
@nkokkos
nkokkos / gist:4f8c8d56bba3762a11fa
Created September 16, 2014 08:13
cache_store.yml and redis.yml files
#cache_store.yml file:
production:
cache_store: redis_store
servers:
- redis://localhost
database: 1
#redis.yml file:
production:
@nkokkos
nkokkos / unicorn.rb
Created September 8, 2014 07:59
Unicorn file for serving Canvas lms
# canvas-lms/config/unicorn.rb:
# Sample verbose configuration file for Unicorn (not Rack)
#
# This configuration file documents many features of Unicorn
# that may not be needed for some applications. See
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
# for a much simpler configuration file.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.