Skip to content

Instantly share code, notes, and snippets.

@ruichuang
Last active November 16, 2016 17:29
Show Gist options
  • Select an option

  • Save ruichuang/a4e8ac8d2ab10eeed46ddbc85db38d79 to your computer and use it in GitHub Desktop.

Select an option

Save ruichuang/a4e8ac8d2ab10eeed46ddbc85db38d79 to your computer and use it in GitHub Desktop.
config vagrant, nginx and node for load balancing
setup seperate vagrant box for nginx and node app, assign different ips for each box.
write script file in vagrant box and config in Vagrantfile:
config.vm.provision "shell", path: "script.sh"
------- script.sh --------
echo "---- start setting up ------"
echo "---- update package list ----"
sudo apt-get update
echo "---- install nvm ----"
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
source $HOME/.nvm/nvm.sh
echo "---- install nodejs ----"
nvm install stable
nvm alias default stable
echo "---- install express ----"
npm install -g express-generator
and then reload the vagrant:
vagrant reload --provision
upstream module in nginx:
upstream app_name {
server srv1.example.com;
server srv2.example.com;
server srv3.example.com;
}
server {
listen 80;
location / {
proxy_pass http://app_name;
}
}
run Apache Bench testing
-install: sudo apt install apache2-utils
-ab -c 40 -n 1000 http://ip.address/
-n requests Number of requests to perform
-c concurrency Number of multiple requests to make
see more: https://www.petefreitag.com/item/689.cfm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment