Categories
Testing

Siege Stress Testing

Download and Configure Siege

  1. sudo apt-get update && sudo apt-get upgrade --show-upgraded
  2. Download the latest version of Siege at Siege’s website:wget http://download.joedog.org/siege/siege-latest.tar.gz
  3. Extract: tar -zxvf siege-latest.tar.gz
  4. cd siege-*/
  5. Install GNU Compiler Collection (gcc):sudo apt-get install build-essential
  6. Configure:./configure make sudo make install
  7. Generate a configuration file:siege.config
  8. Open the .siegerc file located in your home directory.
  9. The suggested Siege configuration is for 25 concurrent users over a period of 1 minute. Set a location for your log file: ~/.siegerc
...

        #
        # Variable declarations. You can set variables here
        # for use in the directives below. Example:
        # PROXY = proxy.joedog.org
        # Reference variables inside ${} or $(), example:
        # proxy-host = ${PROXY}
        # You can also reference ENVIRONMENT variables without
        # actually declaring them, example:
        logfile = $(HOME)/siege.log

...

        #
        # Default number of simulated  concurrent users
        # ex: concurrent = 25
        #
        concurrent = 25

        #
        # Default duration of the siege.  The right hand argument has
        # a modifier which specifies the time units, H=hours, M=minutes,
        # and S=seconds. If a modifier is not specified, then minutes
        # are assumed.
        # ex: time = 50M
        #
        time = 1M

Siege is ready now!

Run Siege

Example URL: www.example.com

siege www.example.com

Siege outputs the results:

** SIEGE 2.70
** Preparing 25 concurrent users for battle.
The server is now under siege...
Lifting the server siege...      done.
Transactions:               2913 hits
Availability:             100.00 %
Elapsed time:              59.51 secs
Data transferred:           0.41 MB
Response time:              0.00 secs
Transaction rate:          48.95 trans/sec
Throughput:              0.01 MB/sec
Concurrency:                 0.04
Successful transactions:         2913
Failed transactions:                0
Longest transaction:             0.01
Shortest transaction:            0.00

FILE: /var/log/siege.log
You can disable this annoying message by editing
the .siegerc file in your home directory; change
the directive 'show-logfile' to false.

If there are no failed connections and the availability remains at 100%, there are no problems.

Advanced Configuring

Creating a URL File

If you want Siege to hit a number of pages on your website at random, configure the program to read from a urls.txt file that lists the selected pages.

  • Open the urls.txt file generally created at /usr/local/etc/urls.txt. Add a list of URLs or IP addresses to that file:/usr/local/etc/urls.txt
# URLS file for siege
# --
# Format the url entries in any of the following formats:
# http://www.whoohoo.com/index.html
# http://www/index.html
# www/index.html
# http://www.whoohoo.com/cgi-bin/howto/display.cgi?1013
# Use the POST directive for pages that require it:
# http://www.whoohoo.com/cgi-bin/haha.cgi POST ha=1&ho=2
#      or POST content from a file:
# http://www.whoohoo.com/melvin.jsp POST </home/jeff/haha
# http://www.whoohoo.com/melvin.jsp POST <./haha
# You may also set and reference variables inside this file,
# for more information, man urls_txt
# -------------------------------------------------------

www.example.com
www.example.org
123.45.67.89
  • To run Siege with this file use the siege command:siege If using a separate file, run:siege -f your/file/path.txt

Commands

Siege features a number of command line options to use when you want to deviate from the default configuration but do not wish to edit the file.

  • -c [num]: Set the number of concurrent users.
  • -t [num]: Set a time limit for which Siege runs. Siege can run with the modifiers s for seconds, m for minutes, or h for hours. There should be no space between the number and the modifier (-t10s not -t10 s).
  • -d [num]: Set the delay for each Siege user. Each user is then delayed for a random amount of seconds in between 1 and the set number. The default value is 3.
  • -i: Used in conjunction with a URLs file, this causes each user to randomly hit one of the URLs, with no predetermined pattern. Similar to real life (the ‘i’ stands for “internet”), where you will not know where site visitors go, not all pages may be hit.
  • -v: Verbose output. This outputs the results Siege gets in real time before printing the final results.
  • -f [file]: Run Siege with a file containing a list of URLs that is not the default urls.txt file.
  • -g [url]: Pull down the HTTP headers.
  • -l: Generates a log file.
  • -m "[message]": Include a message in the log file.
  • -C: Outputs Siege’s current configuration profile.
  • -V: Outputs Siege’s version information.
  • -h: Outputs help information.

Categories
Linux

Jenkins Centos Systemctl Automatic Restart

sudo nano /etc/systemd/system/jenkins.service

Paste the below code in /etc/systemd/system/jenkins.service
Ctrl + O to save
Ctrl + X to exit

[Unit]
Description=Jenkins Server Daemon
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/etc/init.d/jenkins start
Restart=always
RestartSec=3
Type=forking

[Install]
WantedBy=multi-user.target
sudo systemctl enable jenkins.service

To check the list

chkconfig --list
Categories
Apache

Apache2 Handler Configuration

apache2handler

Apache VersionApache/2.0.23 (Debian)
Apache API Version20110210
Server Administratoremail@example.com
Hostname:Portexample.com:0
User/Groupwww-data(33)/33
Max RequestsPer Child: 0 – Keep Alive: on – Max Per Connection: 100
TimeoutsConnection: 300 – Keep-Alive: 5
Virtual ServerYes
Server Root/etc/apache2
Loaded Modulescore mod_so mod_watchdog http_core
mod_log_config mod_logio mod_version mod_unixd
mod_access_compat mod_alias mod_auth_basic
mod_authn_core mod_authn_file mod_authz_core
mod_authz_host mod_authz_user mod_autoindex
mod_deflate mod_dir mod_env mod_fcgid mod_filter
mod_headers mod_mime prefork mod_negotiation
mod_php7 mod_proxy mod_proxy_fcgi
mod_reqtimeout mod_rewrite mod_setenvif
mod_socache_shmcb mod_ssl mod_status
DirectiveLocal ValueMaster Value
engine11
last_modified00
xbithack00
Categories
Web Server

Apache Prefork vs Worker

Prefork

Every request gets its own (memory-separated) process

Worker

Multi-threaded Apache, uses threads instead of processes, is generally faster than prefork and might use less memory

In regards to PHP

As PHP is not thread-safe, the common suggestion is to install Apache with the “prefork” MPM.

Reference: http://www.php.net/manual/en/faq.installation.php#faq.installation.apache2

Note: Debian will automatically choose the right Apache version if you’re installing PHP.

Differences between Apache MPMs

http://httpd.apache.org/docs/2.0/en/mod/#core

Categories
Containers

Packer Dockerfile

FROM alpine:3.11 AS build

ARG PACKER_VERSION="1.4.5"
ARG PACKER_VERSION_SHA256SUM=30da8dab9c526a6d15b037e2234f6f12cf3accfad77eb2c130738ec1a54cab6d

COPY packer_${PACKER_VERSION}_linux_amd64.zip .
RUN echo "${PACKER_VERSION_SHA256SUM}  packer_${PACKER_VERSION}_linux_amd64.zip" > checksum && sha256sum -c checksum

RUN /usr/bin/unzip packer_${PACKER_VERSION}_linux_amd64.zip


FROM ubuntu
RUN apt-get -y update && apt-get -y install ca-certificates && rm -rf /var/lib/apt/lists/*
COPY --from=build packer /usr/bin/packer
ENTRYPOINT ["/usr/bin/packer"]