Skip to content

Instantly share code, notes, and snippets.

Three system configuration parameters must be set to support a large number of open files and TCP connections with large bursts of messages. Changes can be made using the /etc/rc.d/rc.local or /etc/sysctl.conf script to preserve changes after reboot.

1. /proc/sys/fs/file-max: The maximum number of concurrently open files.

fs.file-max = 1000000

2. /proc/sys/net/ipv4/tcp_max_syn_backlog: Maximum number of remembered connection requests, which are still did not receive an acknowledgment from connecting client. The default value is 1024 for systems with more than 128Mb of memory, and 128 for low memory machines.

net.ipv4.tcp_max_syn_backlog = 3240000

3. /proc/sys/net/core/somaxconn: Limit of socket listen() backlog, known in userspace as SOMAXCONN. Defaults to 128.

net.core.somaxconn = 3240000

@melinite
melinite / gs-resample.sh
Created May 19, 2025 04:21 — forked from lkraider/gs-resample.sh
Ghostscript PDF quality downsample
#!/bin/sh
# It seems it's very hard to set resample output quality with Ghostscript.
# So instead rely on `prepress` preset parameter to select a good /QFactor
# and override the options we don't want from there.
gs \
-o resampled.pdf \
-sDEVICE=pdfwrite \
-dPDFSETTINGS=/prepress \
@melinite
melinite / GSCompress.sh
Created May 18, 2025 06:41 — forked from IIPoliII/GSCompress.sh
GhostScript PDF compression of a folder and all the subfolders with multithreading (using screen)
#!/bin/bash
#Variable for choosing the file
FileInput=$1
FileOutput=$2
#GS compression of the pdf
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dNOPAUSE -dBATCH -dDetectDuplicateImages -dCompressFonts=true -r300 -sOutputFile="$FileOutput" "$FileInput"
mv "$FileOutput" "$FileInput"
Understanding Your Google Cloud Costs
# Analyzing Billing Data with BigQuery
SELECT * FROM `billing_dataset.enterprise_billing` WHERE Cost > 0
SELECT Line_Item FROM `billing_dataset.enterprise_billing` GROUP BY Line_Item
SELECT Line_Item, COUNT(*) as NUM FROM `billing_dataset.enterprise_billing` GROUP BY Line_Item
SELECT Project_ID, COUNT(*) as num FROM `billing_dataset.enterprise_billing` GROUP BY Project_ID
SELECT SUM(cost) as Cost, Project_Name FROM `billing_dataset.enterprise_billing` GROUP BY Project_Name
# Visualizing Billing Data with Data Studio
@melinite
melinite / systemd_service_hardening.md
Created April 14, 2024 17:22 — forked from ageis/systemd_service_hardening.md
Options for hardening systemd service units

security and hardening options for systemd service units

A common and reliable pattern in service unit files is thus:

NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
@melinite
melinite / cors-nginx.conf
Created January 25, 2024 13:18 — forked from michiel/cors-nginx.conf
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@melinite
melinite / xtrabackup_runner.sh
Created August 1, 2018 21:17 — forked from sveesible/xtrabackup_runner.sh
A fancier mysql backup script for Xtrabackup:
#!/bin/bash
#
# Script to create full and incremental backups (for all databases on server) using innobackupex from Percona.
# http://www.percona.com/doc/percona-xtrabackup/innobackupex/innobackupex_script.html
#
# Every time it runs will generate an incremental backup except for the first time (full backup).
# FULLBACKUPLIFE variable will define your full backups schedule.
#
# 2012 Brad Svee modified to try to use xbstream
# (C)2012 Atha Kouroussis @ Vurbia Technologies International Inc.
@melinite
melinite / Documentation.md
Created June 27, 2018 13:33 — forked from KartikTalwar/Documentation.md
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
@melinite
melinite / install-java-8-on-ubuntu-14.04-auto-accept-licence-agreement.sh Install oracle Java 8 on Ubuntu 14.04 and automatically accept the licence agreement. 100% hands-free install.
#! /bin/bash
sudo apt-get update
sudo apt-get install -y software-properties-common debconf-utils
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
sudo echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections
sudo apt-get install -y oracle-java8-installer
@melinite
melinite / sendgrid.bash
Created April 26, 2018 14:16 — forked from velizarn/sendgrid.bash
Send email from bash script by using SendGrid API
#!/bin/bash
SENDGRID_API_KEY=""
EMAIL_TO=""
FROM_EMAIL=""
FROM_NAME=""
SUBJECT=""
bodyHTML="<p>Email body goes here</p>"