Posts

Showing posts with the label server

Summary of kubernetes features and terminologies

Image
Introduction Kubernetes had won the container orchestration war. Here is a summary of its features. It's an API, command line and UI. It uses etcd to keep its state. Every thing is done via Yaml or JSON (your choice). General Node : a machine or instance (used to be called "minion") Namespace: a grouping of resources Label: a tag applied to a resource ex. role=frontend Annotations: another form of meta data  Workloads Container  ( spec ) : the building block of deployable service or runnable task using linux containers ex. docker image and params to pass at runtime. Typically created in a Pod see below Pod  ( spec ) : one of more containers scheduled to nodes together and thus can share volumes. Most common pods have a single container but there are use cases for more (ex. nginx and php-fpm) . If you replicate a pod to have 3 replicas it would have 3 nginx and 3 php-fpm. If php-fpm created a file in the volume, nginx can see it. Typically cr...

Let systemd manage your running of unprivileged scripts

Image
Instructions let's save a text file named "test.sh" having the following content #! /bin/bash for i in `seq 50` do    echo $i    sleep 1 done it just print number from 1 to 50 second by second (you can change 50 to any number) now as regular user type chmod +x ./test.sh systemd-run --user --unit=my-test ./test.sh  the above command will run the script as a user service called my-test at any time you can trace it with systemctl and see the logs using journalctl like this journalctl -ln 100 -f --user-unit=my-test systemctl --user status my-test you can abort it using systemctl --user stop my-test Use cases Let's assume you have a web interface that trigger something and you want to trace it later just make your unprivileged web application (written in php/python and running as regular non-root user) called "systemd-run --user" and query the status and follow the logs using systemctl and jou...

Be aware! Docker is a trap.

Image
UPDATE: docker inc. addressed those concerns by donating its runtime to Cloud Native Computing Foundation  (CNCF) and by making moby a community project. Yes, I'm  claiming that Docker is just a hyped vendor lock-in. Don't get me wrong, Linux containers, micro-services, DevOPs,... are all very cool and they are cool for a reason. On the other hand docker is just an overrated vendor lock-in. Linux containers is a new term for old technologies like namespace and control groups, used in production maybe for more than a decade. LXC is one way to access those kernel feature in a boring way. OpenVZ and the newly hyped LXD is virtualization hypervisor based on Linux containers. SystemD do use containers for all of spawned services and can be used to spawn containers (using nspawn ). In other words Docker did not invent containers. I was warned about that more than a year ago but then it was not that obvious. What's wrong with docker? So many things! At every sing...

Boosting performance and concurrency in Python

Image
Python provides a base socket server that got no concurrency support by default, which can be used to create any server including HTTPServer or WSGI applications servers like the wsgiref. You can plugin concurrency support using ThreadingMixIn or ForkingMixIn   this would allow our pure-python server to handle multiple requests by forking another process or starting a new thread while the main thread in the main process keeps accepting requests. In this post I'm going to introduce my own PooledProcessMixIn and its features over other solutions. The concept of Pool BSD mascot with a fork I've taken a look at the code of those Mix-Ins and found serious performance issue with it as they allocate a new process or new thread each time a request comes to the server. Beside delaying the response waiting for the allocation, it's an open-ended approach (no re-using of those threads or processes). The pool approach is to allocate a number of threads or fork a number of pr...