Skip to content

Commit

Permalink
Merge pull request #10 from renatomefi/docs/motivation
Browse files Browse the repository at this point in the history
Document project's motivation
  • Loading branch information
renatomefi authored Sep 13, 2018
2 parents 64442c0 + 12db04b commit 8c61207
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@ With the ascension of containerized applications it becomes more and more useful

This POSIX compliant sh script gets php-fpm status page using `cgi-fcgi` tool, parses it's outcome and allows you to choose a metric which you want to check one, a ping mode is also available which only makes sure php-fpm is answering.

- [Motivation](#motivation)
- [Installation](#installation)
- [Usage](#usage)
- [Kubernetes example](#kubernetes-example)
- [Why POSIX sh?](#why-posix-sh)
- [Author and License](#author)

## Motivation

Previously at work we had Docker containers containing both `php-fpm` and `Nginx` processes, while they were managed by another process being [Supervisord](http://supervisord.org/) or [s6 overlay](https://github.com/just-containers/s6-overlay) for instance.
One good example is [this image from Ric Harvey](https://gitlab.com/ric_harvey/nginx-php-fpm)

It works really well, but I wanted to achieve a few other things like using the official images and its release cycle, logs belonging to their own processes, not mixed, I didn't like to rely on Supervisord since I had bad experiences in the past with it, and other things related to the ["Docker way"](https://docs.docker.com/v17.09/engine/userguide/eng-image/dockerfile_best-practices/), I'm not saying it's perfect but I wanted some of those things.

Now comes the `php-fpm` healthcheck part, while having in place a healthcheck which requested an url in the application asking if it was alive, it was indirectly testing the whole chain, `Nginx -> php-fpm -> application`, and now I had the chance to test still the whole chain via nginx but also monitor how busy and stable is `php-fpm`, if you [check its `/status` page](https://brandonwamboldt.ca/understanding-the-php-fpm-status-page-1603/) it has quite some useful information, so why not monitor on it? For instance you could make a container unhealthy after a certain amount of requests, or if the queue is too long and even slow requests, and that's what this script tries to achieve!

Good news is that you can still do it even using the mixed container approach, but I wanted to take a time to explain why I came to do it like this now! The advantage in my opinion is that having separate containers you have a better grasp on where the problem is laying and you can restart only what's failing, not the whole, also avoiding Supervisord to restart it for you since you are already behind a container orchestration tool.

## Installation

### Enable php-fpm status page
Expand Down
2 changes: 1 addition & 1 deletion test/docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set -eEuo pipefail
function cleanup {
docker stop "$CONTAINER" 1> /dev/null
echo "container $CONTAINER: stopped"
docker rmi "$DOCKER_TAG_TEMPORARY"
docker rmi -f "$DOCKER_TAG_TEMPORARY"
}
trap cleanup EXIT

Expand Down

0 comments on commit 8c61207

Please sign in to comment.