Posts

Showing posts with the label unix

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...

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...