webserver

caddy logline for combined log format

Posted on Updated on

You can use this log line to get the “Combined Log Format” in caddy.

log / stdout “{remote} – – [{when}] \”{method} {path} {proto}\” {status} {size} \”{>Referer}\” \”{>User-agent}\””

or the predefined format “{combined}”

The placeholders are described at https://caddyserver.com/docs/placeholders and the log directive at https://caddyserver.com/docs/log

In case that you are behind a reverves proxy or loadbalancer you will need also to add this directive to the caddy file, to get the real ip.

realip {
from 10.0.0.0/8
}

Of course you will change the from part 😉
The realip directive is described at https://caddyserver.com/docs/realip

check_and_status_ajp

Posted on Updated on

I have searched for a ping for the ajp protocol ( https://tomcat.apache.org/connectors-doc/ajp/ajpv13a.html ) and found some http://lmgtfy.com/?q=ajpping.

From my point of view they have some weakness.

  • not accurate enough for the current it environments
  • don’t measure the operations
  • don’t write a graph-able line out

Due to these facts I have used jffry’s ( http://www.perlmonks.org/?node_id=766945 ) script as base for my extended version.

https://github.com/git001/check_and_status_ajp

With the output line

%Y-%m-%d %T host %s ip %s port %s connect %f syswrite %f sysread %f timeouted %d timeout %d good_answer %d

you can easily create a picture with your preferred tool ( gnuplot, splunk, excel, R, …)

High performance PHP

Posted on Updated on

If you have the need to run php with a very high traffic you should think about the follwoing setup.

Don’t think it will work in 5 minutes and you don’t need some knowledge about how to setup an webserver and a php application, you definitely need it.

If you think this is a step by step description for people which only want to copy and past commands and it works then you are wrong here, please take a websearch engine for a alternative description.

What you need:

  1. nginx http://www.nginx.net/
  2. php-fm http://php-fpm.org/
  3. php http://www.php.net/
  4. a compile environment
  5. the development libraries for the wanted php features and libxml2
  6. A clear test scenario and target how many requests per second should be reached on static and dynamic part.

How you can build this environment:

  1. Extract, build and install nginx http://wiki.nginx.org/NginxGettingStarted
  2. Extract, build and install php-fm http://php-fpm.org/wiki/Documentation
  3. configure nginx for fast-cgi proxying http://wiki.nginx.org/NginxHttpFcgiModule

High Performance View

A brief description how the flow is:

  • A request comes to nginx
  • He takes a look into his config to find the right location or server config
  • If the static content rule matches then he will deliver the content directly from the disc
  • If the dynamic rule matches the he will contact php-fm, which manage the php-instances
  • php-fm execute the php script and send the dynamic content back to nginx
  • nginx sends the content back to the client

There are some pitfalls:

  1. client_body_buffer_size
  2. fastcgi_buffers*

You should take your time to find the right config setup for nginx and php-fm to be able to fulfill the assumed traffic.

I have started to translate the russian documentation, which is still not complete.

UPDATE: There is now a official wiki http://php-fpm.org/

use the event ports in nginx

Posted on

Solaris have since version 10 a new polling infrastrucutre Event Ports here a more detailed article about Event Completion Framework. Adam Leventhal wrotes in his Blog for him this is one of the top 20 best thing in Solaris 10.

By default nginx do not use this event methode due to the fact that there was some security related problems Security Vulnerabilities in The Solaris Event Port API May Result in a Denial of Service (DoS) Condition and  Vulnerability in the Solaris 10 Event Port Implementation May Lead to a System Panic, Resulting in a Denial of Service (DoS) if you have a newer Version or applied the Patch you should use the event ports in nginx.

You only need to add

use eventport;

in the events { … } section. If you don’t add this then nginx by default us the /dev/poll method.

More about the possible polling methods can be found here.

nginx build on opensolaris with SunStudio

Posted on Updated on

Today I was interested if the latest nginx (nginx-0.7.1) is able to build on the opensolaris box and YES it does 😉

1.) get it

wget http://sysoev.ru/nginx/nginx-0.7.1.tar.gz

2.) extract it

gtar xfvz nginx-0.7.1.tar.gz

3.) build it

cd nginx-0.7.1 && ./configure –prefix=$HOME/servers/nginx –with-http_ssl_module –with-debug –with-cc=/opt/SunStudioExpress/bin/cc

It’s so easy, thanks Igor.