Tuning the Linux Kernel and TCP Parameters with Sysctl

There are many guides online about Linux kernel and TCP tuning, I tried to sum the most useful and detailed Linux kernel and TCP tuning tips, including the best guides about TCP and kernel tuning on Linux, useful to scale and handle more concurrent connections on a linux server. Time ago I wrote about optimizing […]

Find how much memory TCP actually uses on Linux

View how much memory TCP actually uses on a Linux server. Type this command: cat /proc/net/sockstatcat /proc/net/sockstat This is an example output: sockets: used 789 TCP: inuse 476 orphan 21 tw 6242 alloc 479 mem 304 UDP: inuse 37 mem 14 UDPLITE: inuse 0 RAW: inuse 0 FRAG: inuse 0 memory 0sockets: used 789 TCP: […]

Increase Dom0 RAM Memory in XenServer 6

Configure Control Domain (dom0) RAM memory in XenServer 6.1.0 and later: 1) SSH login as root on the XenServer host 2) Enter the following command to increase the RAM to 4GB: /opt/xensource/libexec/xen-cmdline –set-xen dom0_mem=4096M,max:4096M/opt/xensource/libexec/xen-cmdline –set-xen dom0_mem=4096M,max:4096M 3) Shutdown all running VMs to avoid data loss: *** This command may not be recommended for a pooled […]

Run a Bash Script at Startup\Boot on Debian Linux

Run a script at startup on Debian Linux: *** Recommended only for “just scripts” and not daemons *** Option 1 Edit /etc/rc.local like this: #!/bin/sh -e #(Multiple-lines of comments removed) /usr/local/bin/your-script.sh exit 0#!/bin/sh -e #(Multiple-lines of comments removed) /usr/local/bin/your-script.sh exit 0 Option 2 Edit /etc/crontab like this: #(Multiple-lines of comments removed) @reboot root /usr/local/bin/your-script.sh#(Multiple-lines of […]

Get Public IP (IPv4) Address of your Linux Server

Bash shell command to get the public IPv4 address of eth0 on Debian Linux: ifconfig eth0 | grep ‘inet’ | awk ‘{print $2}’ | sed ‘s/addr://’ | grep .ifconfig eth0 | grep ‘inet’ | awk ‘{print $2}’ | sed ‘s/addr://’ | grep . It will print the public IPv4 address of your server.

InnoSetup Disable Select Destination Location

To disable InnoSetup “Select Destination Location” wizard page: Add this variable under [Setup] section: DisableDirPage=noDisableDirPage=no More information here: [Setup]: DisableDirPage

InnoSetup Disable Close of Applications

If you already handle the termination of your applications’s processes inside the CurStepChanged -> ssInstall then you may want to disable the display of the form “The following applications are using files that need to be updated by Setup”: To do so, just add this variable under [Setup] section: CloseApplications=noCloseApplications=no More information can be found […]

Node.js Execute a Unix Command

Use child_process.exec to execute a comand and fetch its output: var exec = require(‘child_process’).exec; var cmd = ‘id’;   exec(cmd, function(error, stdout, stderr) { console.log("Output: "+stdout); });var exec = require(‘child_process’).exec; var cmd = ‘id’; exec(cmd, function(error, stdout, stderr) { console.log("Output: "+stdout); }); Or you can use execFile() method: var execFile = require(‘child_process’).execFile;   execFile("/bin/ls", [‘-la’], […]

Node.js Cluster Module

Example Node.js cluster module usage: var cluster = require(‘cluster’); var http = require(‘http’); var numCPUs = require(‘os’).cpus().length;   if (cluster.isMaster) { // Fork workers. for (var i = 0; i < numCPUs; i++) { cluster.fork(); }   cluster.on(‘exit’, function(worker, code, signal) { console.log(‘worker ‘ + worker.process.pid + ‘ died’); }); } else { // Workers […]

Install Node.js on Debian 8 Jessie

Download this bash script to update the PPA and apt repos: curl -sL https://deb.nodesource.com/setup_7.x -o nodesource_setup.shcurl -sL https://deb.nodesource.com/setup_7.x -o nodesource_setup.sh * Replace 7.x with the last Node.js version Grant +x permissions to the bash script: chmod +x nodesource_setup.shchmod +x nodesource_setup.sh Run the bash script: bash nodesource_setup.shbash nodesource_setup.sh Now install Node.js (it contains also npm): apt-get […]