Skip to content

Instantly share code, notes, and snippets.

View nguyentuandat's full-sized avatar
🏠
Working from home

Nguyễn Tuấn Đạt nguyentuandat

🏠
Working from home
View GitHub Profile
@nguyentuandat
nguyentuandat / nginx-tuning.md
Created June 25, 2021 15:41 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

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.

@nguyentuandat
nguyentuandat / steps.md
Created March 4, 2021 10:35 — forked from mraaroncruz/steps.md
Get the Telegram channel ID

To get the channel id

  1. Create your bot with botfather
  2. Make you bot an admin of your channel

New improved next steps

  1. Go to https://web.telegram.org
  2. Click on your channel
  3. Look at the URL and find the part that looks like c12112121212_17878787878787878
  4. Remove the underscore and after c12112121212
@nguyentuandat
nguyentuandat / archive-book.php
Created December 4, 2020 00:47
archive-book.php
<?php
/**
* The template for displaying archive pages
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
*
* @package WordPress
* @subpackage Twenty_Seventeen
* @since Twenty Seventeen 1.0
* @version 1.0
@nguyentuandat
nguyentuandat / function.php
Created December 4, 2020 00:44
Example register post type and taxonomy
function wporg_custom_post_type() {
register_post_type('book',
array(
'labels' => array(
'name' => __('Books', 'textdomain'),
'singular_name' => __('Book', 'textdomain'),
),
'public' => true,
'has_archive' => true,
# get total requests by status code
awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort -rn
# get top requesters by IP
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head | awk -v OFS='\t' '{"host " $2 | getline ip; print $0, ip}'
# get top requesters by user agent
awk -F'"' '{print $6}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head
# get top requests by URL
@nguyentuandat
nguyentuandat / thich.dev.conf
Last active July 8, 2020 18:34
FastCGI Cache
server {
server_name thich.dev;
location / {
try_files $uri $uri/ /index.php?$args;
}
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
location ~ \.php$ {