Skip to content

Instantly share code, notes, and snippets.

View hendra's full-sized avatar

Hendra Nicholas hendra

View GitHub Profile
@hendra
hendra / ngxpagespeed.conf
Created August 6, 2018 05:57
Nginx Pagespeed Configuration
# Enable pagespeed module by putting the following in http context
pagespeed on;
pagespeed Domain example.com;
pagespeed DownstreamCachePurgeLocationPrefix http://lb1.i;
pagespeed DownstreamCachePurgeMethod PURGE;
pagespeed DownstreamCacheRewrittenPercentageThreshold 95;
# This setting should be enabled when using HTTPS
@hendra
hendra / .gemrc
Created August 6, 2018 00:22
gemrc
---
# The paths in which to look for gems
# :gempath:
# Force specification of gem server host on push
# disable_default_gem_server:
# A YAML array of remote gem repositories to install gems from
# :sources:
@hendra
hendra / limits.conf
Created August 5, 2018 23:57
Security Limits
* soft nofile 20000000
* hard nofile 20000000
* soft nproc 8192
* hard nproc 8192
@hendra
hendra / nginx.ngxpagespeed.sh
Last active August 5, 2018 23:59
Install Nginx Pagespeed With SSL & HTTP2 Modules
bash <(curl -f -L -sS https://ngxpagespeed.com/install) \
--nginx-version latest \
--additional-nginx-configure-arguments '--with-http_ssl_module --with-http_v2_module'
@hendra
hendra / openvpn-install.sh
Created August 2, 2018 11:03
OpenVPN road warrior installer for Debian, Ubuntu and CentOS.
wget https://git.io/vpn -O openvpn-install.sh && bash openvpn-install.sh
@hendra
hendra / puma.rb
Last active August 5, 2018 19:21
Puma Config
#!/usr/bin/env puma
require 'puma_worker_killer'
require 'concurrent'
# Change to match your CPU core count
workers Concurrent.processor_count || 1
# Min and Max threads per worker
min_thread = ENV['RAILS_MIN_THREADS'] || 0
@hendra
hendra / OS X network optimize.txt
Last active March 5, 2020 11:06 — forked from snoby/OS X network optimize.txt
OSX Sierra Network & System Performance Tweaks
#
# Reboot into recovery mode (cmd +r ) and in the terminal
#
nvram boot-args="serverperfmode=1 ncl=262144"
#reboot
#
# In regular mode
@hendra
hendra / bench_rails_memory_usage.rb
Created June 30, 2018 09:44 — forked from brianhempel/bench_rails_memory_usage.rb
A script to test the memory usage of your Rails application over time. It will run 30 requests against the specified action and report the final RSS. Choose the URL to hit on line 45 and then run with `ruby bench_rails_memory_usage.rb`.
require "net/http"
def start_server
# Remove the X to enable the parameters for tuning.
# These are the default values as of Ruby 2.2.0.
@child = spawn(<<-EOC.split.join(" "))
XRUBY_GC_HEAP_FREE_SLOTS=4096
XRUBY_GC_HEAP_INIT_SLOTS=10000
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0
@hendra
hendra / nginx.conf
Last active August 6, 2018 05:51 — forked from v0lkan/nginx.conf
Configuring NGINX for Maximum Throughput Under High Concurrency
user nobody nogroup;
# One worker process per CPU core.
worker_processes 2;
# Also set
# /etc/security/limits.conf
# web soft nofile 65535
# web hard nofile 65535
# /etc/default/nginx
@hendra
hendra / install_ngxpagespeed.sh
Last active June 23, 2018 14:00
Install ngxpagespeed with some additional modules
cd /tmp
git clone https://github.com/vozlt/nginx-module-vts.git
git clone https://github.com/openresty/headers-more-nginx-module.git
sudo apt-get install libgeoip-dev libssl-dev
sudo mkdir /usr/local/share/GeoIP
sudo mkdir /usr/local/nginx/conf/conf.d
wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz