https://iximiuz.com/Ivan on Containers, Kubernetes, and Server-Side2022-11-30T10:57:12.219ZawesomeIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/Want to learn Containers and Kubernetes internals? Struggle to understand what this Cloud Native buzz is about? On a mission to master the Server-Side craft? Then this site is for you!https://iximiuz.com/favicon.icoAll rights reserved 2022, Ivan Velichkohttps://iximiuz.com/en/posts/docker-publish-port-of-running-container/2022-11-30T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/docker-publish-container-ports/2022-11-27T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/ssh-tunnels/2022-10-30T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/docker-debug-slim-containers/2022-10-08T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/docker-image-to-filesystem/2022-09-19T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/containers-distroless-images/2022-09-04T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/containers-making-images-better/2022-08-20T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/kubernetes-vs-virtual-machines/2022-07-31T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/how-to-start-programming-in-go-for-devops/2022-06-01T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/kubernetes-ephemeral-containers/2022-05-29T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/kubernetes-api-go-cli/2022-05-14T00:00:00.000Z Set of helpers for creating kubectl commands, as well as kubectl plugins.
This library is a shared dependency for clients to work with Kubernetes API infrastructure which allows to maintain kubectl compatible behavior.
If the above description didn't sound too impressive, let me try to decipher it for you - with the cli-runtime library, you can write CLI tools that behave like and are as potent as the mighty kubectl!
Here is what you actually can achieve with just a few lines of code using the cli-runtime library:
- Register the well-know flags like `--kubeconfig|--context|--namespace|--server|--token|...` and pass their values to one or more client-go instances.
- Look up cluster objects by their resources, kinds, and names with the full-blown support of familiar shortcuts like `deploy` for `deployments` or `po` for `pods`.
- Read and kustomize YAML/JSON Kubernetes manifests into the corresponding Go structs.
- Pretty-print Kubernetes objects as YAML, JSON (with JSONPath support), and even human-readable tables!
Interested? Then have a look at the usage examples below 😉
]]>Ivan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/containers-101-container-mgmt-commands/2022-04-26T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/containers-learning-docker-with-docker/2022-04-15T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/kubernetes-api-how-to-extend/2022-03-24T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/go-io-tee-reader-and-multi-writer/2022-02-20T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/kubernetes-api-go-types-and-common-machinery/2022-01-24T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/kubernetes-api-call-simple-http-client/2022-01-16T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/kubernetes-api-structure-and-terminology/2022-01-09T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/containers-101-attach-vs-exec/2021-12-18T00:00:00.000ZIvan Velichkoiximiuz@gmail.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/openfaas-case-study/2021-12-02T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/container-learning-path/2021-11-14T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/containers-vs-pods/2021-10-28T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/learn-by-doing-platforms/2021-10-03T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/reverse-proxy-http-keep-alive-and-502s/2021-09-30T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/containerd-command-line-clients/2021-09-12T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/oci-containers/2021-09-05T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/multiple-containers-same-port-reverse-proxy/2021-08-28T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/go-net-http-setsockopt-example/2021-08-19T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/how-to-setup-development-environment/2021-08-03T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/devops-sre-and-platform-engineering/2021-08-01T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/my-choice-of-programming-languages/2021-07-28T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/prometheus-is-not-a-tsdb/2021-07-24T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/prometheus-learning-promql/2021-07-24T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/prometheus-metrics-labels-time-series/2021-07-24T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/rust-writing-parsers-with-nom/2021-07-22T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/pq/2021-07-08T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/prometheus-functions-agg-over-time/2021-06-28T00:00:00.000Z_over_time()`. They can be applied only to range vectors. It essentially makes them window aggregation functions. Every such function takes in a range vector and produces an instant vector with elements being per-series aggregations. For people like me who normally grasp code faster than text, here is some pseudocode of the aggregation logic...
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/prometheus-vector-matching/2021-06-13T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/thick-container-vulnerabilities/2021-06-02T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/rust-privacy-and-visibility/2021-05-15T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/bridge-vs-switch/2021-03-28T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/computer-networking-101/2021-03-21T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/kubernetes-kind-load-docker-image/2021-02-13T00:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/go-http-handlers-panic-and-deadlocks/2021-02-06T17:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/kubernetes-operator-pattern/2021-01-31T13:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/writing-web-server-in-python-sockets/2020-12-27T15:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/making-sense-out-of-cloud-native-buzz/2020-12-10T19:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/service-discovery-in-kubernetes/2020-12-06T15:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/api-developers-never-rest/2020-11-21T20:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/container-networking-is-simple/2020-10-18T17:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/traefik-canary-deployments-with-weighted-load-balancing/2020-09-20T16:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/service-proxy-pod-sidecar-oh-my/2020-09-06T15:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/you-need-containers-to-build-an-image/2020-05-25T14:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/you-dont-need-an-image-to-run-a-container/2020-05-16T22:00:00.000Zisolated and restricted Linux processes. We also learned that it's fairly simple to create a container with a single executable file inside starting from _scratch_ image (i.e. without putting a full Linux distribution in there). This time we will go even further and demonstrate that containers don't require images at all. And after that, we will try to justify the actual need for images and their place in the _containerverse_.
You might have heard that Docker uses a tool called _runc_ to run containers. Well, to be more accurate, Docker depends on a lower-level piece of software called _containerd_ which in turn relies on a standardized container runtime implementation. And in the wild, most of the time _runc_ plays the role of such a component.]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/not-every-container-has-an-operating-system-inside/2020-05-07T19:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/working-with-container-images-in-go/2020-03-01T17:00:00.000Zmy experimental container manager and to my surprise, the task turned to be more complex than I initially expected. I spent some time looking for ways to manage container images directly from my application code. There is plenty of tools out there (_docker_, _containerd_, _podman_, _buildah_, _cri-o_, etc) providing image management capabilities. However, if you don't want to have a dependency on an external daemon running in your system, or you don't feel like shelling out for _exec_-ing a command-line tool from the code, the options are at best limited.
I've reviewed a bunch of the said tools focusing on the underlying means they use to deal with images and at last, I found two appealing libraries. The first one is github.com/containers/image library "[...] aimed at working in various way with containers' images and container image registries". The second one is github.com/containers/storage"[...] which aims to provide methods for storing filesystem layers, container images, and containers". The libraries are meant to be used in conjunction and form a very powerful image management tandem. But unfortunately, I could not find a sufficient amount of documentation, especially _how to get started_ kind of it.
Without the docs the only way to learn how to use the libraries for me was to analyze the code of their dependants (most prominently - buildah and cri-o). It took me a while to forge a working example which is capable of:
- pulling images from remote repositories;
- storing images locally;
- creating and mounting _containers_ (i.e. writable instances of images).
In the rest of the article, I'll try to show how to use the libraries to perform the said task and highlight the most interesting parts of this journey.
Disclaimer: This is by no means an attempt to fully or even partially document the libraries!
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/master-go-while-learning-containers/2020-02-03T21:40:00.000Zdeep-diving into the world of containers and their orchestration. I have been enjoying it very much and learned a lot. On my journey, I need to tackle lots of interesting and specific concepts. But there is one commonality almost every project in this area possesses. When it comes to containers - the Go programming language is ubiquitous!
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/implementing-container-runtime-shim-3/2020-01-26T14:20:00.000Zthe scope of the container runtime shim and drafted the minimum viable version. Now, it's time to move on and have some fun with more advanced scenarios! Have you ever wondered how `docker run -i` or `kubectl run --stdin` work? If so, this article is for you! We will try to replicate this piece of functionality in our experimental container manager. And as you have probably guessed, the container runtime shim will do a lot of heavy lifting here again.
https://www.youtube.com/embed/Vz4qH-OVWPo
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/flask-gevent-tutorial/2019-12-27T00:00:00.000ZPython is booming and Flask is a pretty popular web-framework nowadays. Probably, quite some new projects are being started in Flask. But people should be aware, it's synchronous by design and ASGI is not a thing yet. So, if someday you realize that your project really needs asynchronous I/O but you already have a considerable codebase on top of Flask, this tutorial is for you. The charming gevent library will enable you to keep using Flask while start benefiting from all the I/O being asynchronous. In the tutorial we will see:
- How to monkey patch a Flask app to make it asynchronous w/o changing its code.
- How to run the patched application using gevent.pywsgi application server.
- How to run the patched application using Gunicorn application server.
- How to run the patched application using uWSGI application server.
- How to configure Nginx proxy in front of the application server.
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/my-10-years-of-programming-experience/2019-12-22T20:00:00.000ZRegardless of whether it's the end of the calendar decade or not it's the end of a programming decade for me. I started early in 2010 and since then I've been programming almost every day, including weekends and vacations. This was a really exciting period in my life and I realized that it's been a while since 2010 only recently. So, I decided to put into words some of my learnings from that time. Warning: the content of this article is highly opinionated and extremely subjective.
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/implementing-container-runtime-shim-2/2019-12-18T21:00:00.000Zwhat we need to deal with. In order to use _runc_ from code we need to implement our shim as a daemon and this daemon has to be as long-lived as the underlying container process. In this article, we will try to develop a minimum viable runtime shim and integrate it with our experimental container manager.
The minimal shim implementation takes as its input a path to the container bundle (with the `config.json`) as well as the list of the predefined locations (for the container log file, container pidfile, container exit status file, etc). The shim needs to create a container by executing _runc_ with the provided parameters and then serve the container process until its termination. The planned functionality of this shim version includes:
- Detaching the shim from the container manager process.
- Launching _runc_ and handling container creation errors.
- Reporting the status of the container creation back to the manager.
- Streaming container's _stdout_ and _stderr_ to the log file.
- Tracking and reporting the exit code of the container.
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/implementing-container-runtime-shim/2019-12-15T20:00:00.000ZA container runtime shim is a piece of software that resides in between a container manager (_containerd_, _cri-o_, _podman_) and a container runtime (_runc_, _crun_) solving the integration problem of these counterparts.
The easiest way to spot a shim is to inspect the process tree on a Linux host with a running docker container:
On the one hand, runtimes need shims to be able to survive managers restarts. On the other hand, shims are helping container managers to deal with the quirky behavior of runtimes. As a part of the container manager implementation series, we will try to create our own shim and then integrate it with _conman_, an experimental container manager. Hopefully, during the development, we will gain an in-depth understanding of the topic.
However, before jumping to the shim development, we need to familiarize ourselves with the container runtime component of the choice. Unsurprisingly, _conman_ uses _runc_ as a container runtime, so I will start the article by covering basic _runc_ use cases alongside its design quirks. Then I'll show the naive way to use _runc_ from code and explain some related pitfalls. The final part of the article will provide an overview of the shim's design.]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/kubernetes-repository-on-flame/2019-11-17T21:00:00.000Z`tree`. However, not every project is perfectly balanced. Some files and folders tend to be more popular and contain much more code than others. Seems like yet another incarnation of the Pareto principle.
So, when the `tree`'s capabilities aren't enough, I jump to `cloc`. This tool is much more powerful and can show nice textual statistics for the number of code lines and programming languages used per the whole project or per each file individually.
However, some projects are really huge and some lovely visualization would be truly helpful! And here the FlameGraph goes! What if we feed the `cloc`'s output for the Kubernetes codebase to FlameGraph? Thanks to the author of this article for the original cloc-to-flamegraph one-liner:
```bash
git clone https://github.com/brendangregg/FlameGraph
go get -d github.com/kubernetes/kubernetes
cd $(go env GOPATH)/src/github.com/kubernetes/kubernetes
cloc --csv-delimiter="$(printf '\t')" --by-file --quiet --csv . | \
sed '1,2d' | \
cut -f 2,5 | \
sed 's/\//;/g' | \
~/FlameGraph/flamegraph.pl \
--width=3600 \
--height=32 \
--fontsize=8 \
--countname=lines \
--nametype=package \
> kubernetes.html
open kubernetes.html
```
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/dealing-with-processes-termination-in-Linux/2019-10-20T13:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/conman-the-container-manager-inception/2019-10-06T12:00:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/journey-from-containerization-to-orchestration-and-beyond/2019-08-18T11:00:00.000Z1, 2, 3, 4, ...) describing different aspects of the containers universe. Of course, on the lowest level lie Linux primitives such as _namespaces_ and _cgroups_. But containerization software is already so massive that it would be barely possible to implement it without its own concern separation layers. What I'm trying to achieve in this **_ongoing effort_** is to guide myself starting from the lowest layers to the topmost ones, having as much practice (code, installation, configuration, integration, etc) and, of course, **_fun_** as possible. The content of this page is going to be changing over time, reflecting my understanding of the topic.]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/linux-pty-what-powers-docker-attach-functionality/2019-08-11T21:30:00.000ZLinux pseudoterminal capabilities and continuously shows how attach-like feature can be implemented in a ridiculously small amount of code.
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/laymans-iptables-101/2019-06-21T15:30:00.000Zdefinitions here nor long lists of useful commands. I would rather try to use layman's terms and scribbling as much as possible to give you some insights about the domain before going to all these _tables_, _rules_, _targets_, and _policies_. By the way, the first time I faced this tool I was pretty much confused by the terminology too!]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/from-docker-container-to-bootable-linux-disk-image/2019-06-09T22:05:00.000Z`docker export`, however, to finally accomplish the task a bunch of additional steps is needed...]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/ru/posts/writing-python-web-server-part-3/2019-05-19T12:50:00.000Zотправлять и принимать данные по сети и организовывать обработку запросов на сервере. Настало время перейти на более высокий уровень - реализовать свой HTTP сервер.
Для начала определимся, что же такое HTTP. Hypertext Transfer Protocol (HTTP) - это протокол прикладного уровня, предназначенный для передачи гипертекстовых данных в распределенных информационных системах. Ух, сложнааа... А на самом деле нет. Давайте разбираться!
Протокол - это не более, чем соглашение между двумя или более участниками некоторого взаимодействия. Когда речь идет о сетевом взаимодействии, протоколы принято условно разделять на уровни. В самом низу находятся протоколы физического уровня, определяющие как данные передаются в физических средах, т.е. по проводам, оптоволокну, и т.п. Знакомые нам из первой части протоколы IP и TCP - это протоколы сетевого и транспортного уровня, соответственно. Они определяют более высокоуровневые детали взаимодействия, в частности, IP отвечает за адресацию компьютеров/узлов в сети, а TCP - за надежную передачу данных произвольной (т.е. в общем случае превышающей размер одного IP-пакета) длины между узлами. HTTP же располагается на самом высоком уровне - прикладном. От нижележащих протоколов HTTP ожидает гарантий надежности доставки данных, а сам концентрируется на определении понятий запросов и ответов (сообщений) и их семантике. Фактически, HTTP является основным протоколом передачи данных в вебе, а сами данные являются гипертекстом, зачастую представленным в формате HTML-страниц.
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/ru/posts/over-9000-ways-to-make-web-server-in-python/2019-05-02T21:24:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/from-callback-hell-to-async-await-heaven/2019-05-02T13:26:00.000Zprevious article, we learned how to implement a simple but workable event loop. However, programs which are supposed to be run by the event loop are full of callbacks. This is the usual problem of _event-loop-driven environments_. When business logic becomes reasonably complicated, callbacks make program's code hardly readable and painfully maintainable. **And the callback hell begins!** There is plenty of ways to deal with the artificial complexity arose due to callbacks, but the most impressive one is to make the code ~~_great_~~ _flat_ again. And by _flat_, I mean callback-less and synchronous-like. Usually, it's done by introducing `async/await` syntactic feature. But every high-level abstraction is built on top of some basic and fundamental ideas. Let's check the `async/await` sugar out and see what exactly happens under the hood.
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/explain-event-loop-in-100-lines-of-code/2019-04-25T16:30:00.000Zevent loop. However, as a software engineer, I prefer to read code, not text. And there is no better way of learning a new concept than implementing it yourself. So, let's try to grasp the idea of the event loop by coding a new one.
In the article, we will try to describe the idea of the event loop in general, not a specific implementation of the event loop in Node.js or Python, or some other language/library.
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/save-the-day-with-gevent/2019-04-17T17:26:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/ru/posts/writing-python-web-server-part-2/2019-04-14T13:00:00.000Zпрошлой части мы познакомились с TCP-сокетами, как инструментом передачи данных по сети, основами их использования на стороне сервера и клиента. В этот раз речь пойдет про обработку запросов. Существует множество способов организации обработки запросов сервером: _один клиент - один процесс_, _один клиент - один поток_, _много клиентов - один поток с асинхронным I/O_, а также _гибридные_ подходы. Мы рассмотрим основные моменты каждого из подходов, их достоинства и недостатки.
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/truly-optional-scalar-types-in-protobuf3/2019-04-10T20:15:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/nodejs-writable-streams-distilled/2019-04-07T21:15:00.000ZWritable streams are an abstraction for a destination to which data is written... And this time it's a concise abstraction! Compared to vague readable streams (multiple operation modes behind single abstraction) writable streams implement only one mode and hence expose only one essential method `write(chunk)`. Nevertheless, the idea of writable streams is not trivial and it's due to one nice feature it provides - backpressure. Let's try to wrap our mind around writable stream abstraction.
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/nodejs-readable-streams-distilled/2019-03-17T21:44:00.000ZReadable stream is an abstraction for some data source. Which could be hard to grasp and even harder to use...
Everybody knows that readable streams support two modes of operating (_flowing_ and _paused_) and piping to writable streams. It's not that easy to understand the purposes of these mechanisms and behavioral differences though. Since _one readable stream_ abstraction stands for _multiple usage modes_ its public interface (i.e. the set of methods and events) is a bit inconsistent. Usage of readable streams might be totally confusing without the understanding of the underlying ideas. In this article, we will make an attempt to justify the abstraction of readable streams trying to implement our own file reader. Also, we will have a look at some nicer ways to consume readable streams.
]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/en/posts/how-to-on-processes/2018-01-30T21:10:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/ru/posts/digest-links-july-2016/2016-07-31T08:39:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/ru/posts/writing-python-web-server-part-1/2016-04-13T19:14:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/ru/posts/javascript-inheritance/2016-01-17T15:41:00.000ZНаследование** - это один из способов повторного использования кода. Оно бывает двух типов: на основе классов (*class-based*) и прототипное (*prototypal*). В любом случае, так как речь про объектно-ориентированное программирование, наследование - это про создание *множества объектов, обладающих общими свойствами*, на основе уже *существующих*.]]>Ivan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/https://iximiuz.com/ru/posts/handicrafts/2016-01-08T12:32:00.000ZIvan Velichkoivan@iximiuz.comhttps://iximiuz.com/en/about/