Skip to content

Instantly share code, notes, and snippets.

View armeo's full-sized avatar

Adisorn Chockaumnuai armeo

View GitHub Profile
@armeo
armeo / logrotate-nginx
Created February 15, 2021 12:43 — forked from aputs/logrotate-nginx
logrotate config for nginx
/var/log/nginx_*.log {
daily
compress
delaycompress
rotate 2
missingok
nocreate
sharedscripts
postrotate
test ! -f /var/run/nginx.pid || kill -USR1 `cat /var/run/nginx.pid`
@armeo
armeo / sysctl.conf
Created April 22, 2019 05:03 — forked from maprangzth/sysctl.conf
ubuntu sysctl performance tuning
# Kernel sysctl configuration file for Linux
#
# Version 1.12 - 2015-09-30
# Michiel Klaver - IT Professional
# http://klaver.it/linux/ for the latest version - http://klaver.it/bsd/ for a BSD variant
#
# This file should be saved as /etc/sysctl.conf and can be activated using the command:
# sysctl -e -p /etc/sysctl.conf
#
# For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and sysctl.conf(5) for more details.
@armeo
armeo / grafana custom.ini
Created November 9, 2016 09:54 — forked from mvadu/grafana custom.ini
nginx config for using grafana, Influxdb via reverse proxy with authentication
# The full public facing url
#root_url = %(protocol)s://%(domain)s:%(http_port)s/
root_url = http://localhost:80/grafana/
@armeo
armeo / nginx-tuning.md
Created September 19, 2016 14:53 — 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 400,000 to 500,000 requests per second (clustered), most what i saw is 50,000 to 80,000 (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.

@armeo
armeo / post-mortem.md
Created September 19, 2016 05:24 — forked from joewiz/post-mortem.md
Recovery from nginx "Too many open files" error on Amazon AWS Linux

On Tue Oct 27, 2015, history.state.gov began buckling under load, intermittently issuing 500 errors. Nginx's error log was sprinkled with the following errors:

2015/10/27 21:48:36 [crit] 2475#0: accept4() failed (24: Too many open files) 2015/10/27 21:48:36 [alert] 2475#0: *7163915 socket() failed (24: Too many open files) while connecting to upstream...

An article at http://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/ provided directions that mostly worked. Below are the steps we followed. The steps that diverged from the article's directions are marked with an *.

    • Instead of using su to run ulimit on the nginx account, use ps aux | grep nginx to locate nginx's process IDs. Then query each process's file handle limits using cat /proc/pid/limits (where pid is the process id retrieved from ps). (Note: sudo may be necessary on your system for the cat command here, depending on your system.)
  1. Added fs.file-max = 70000 to /etc/sysctl.conf
  2. Added `nginx soft nofile 1
@armeo
armeo / boto3_hands_on.md
Created September 5, 2016 17:22 — forked from iMilnb/boto3_hands_on.md
Programmatically manipulate AWS resources with boto3 - a quick hands on

boto3 quick hands-on

This documentation aims at being a quick-straight-to-the-point-hands-on AWS resources manipulation with [boto3][0].

First of all, you'll need to install [boto3][0]. Installing it along with [awscli][1] is probably a good idea as

  • [awscli][1] is boto-based
  • [awscli][1] usage is really close to boto's
@armeo
armeo / ec2_auto_stop_start.py
Created September 5, 2016 14:23 — forked from srs81/ec2_auto_stop_start.py
Python: Auto start and stop EC2 instances at certain times of the day
#!/usr/bin/python
#
# Auto-start and stop EC2 instances
#
import boto, datetime, sys
from time import gmtime, strftime, sleep
# AWS credentials
aws_key = "AKIAxxx"
aws_secret = "abcd"
package main
import (
"database/sql"
"gopkg.in/gorp.v1"
"log"
"strconv"
"github.com/gin-gonic/gin"
_ "github.com/go-sql-driver/mysql"
@armeo
armeo / sql.gradle
Last active August 29, 2015 14:23 — forked from skhatri/sql.gradle
import org.apache.commons.dbcp.BasicDataSource
apply plugin:'eclipse'
propFile="${rootProject.projectDir}/config/database.properties"
prod=false
buildscript {
buildDeps = ['commons-pool:commons-pool:1.5.4', 'commons-io:commons-io:2.0.1', 'commons-dbcp:commons-dbcp:1.3',
'mysql:mysql-connector-java:5.1.13']
apply plugin: 'checkstyle'
checkstyleMain {
ignoreFailures = false
reports {
include ( '**/*.java')
xml {
destination "${rootProject.buildDir}/reports/checkstyle/main.xml"
}
}