{"id":96515,"date":"2020-10-12T19:43:02","date_gmt":"2020-10-12T17:43:02","guid":{"rendered":"https:\/\/prohoster.info\/blog\/administrirovanie\/odyssey-roadmap-chto-eshhyo-my-hotim-ot-pulera-soedinenij-andrej-borodin-2019"},"modified":"2020-10-12T19:43:02","modified_gmt":"2020-10-12T17:43:02","slug":"odyssey-roadmap-chto-eshhyo-my-hotim-ot-pulera-soedinenij-andrej-borodin-2019","status":"publish","type":"post","link":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/odyssey-roadmap-chto-eshhyo-my-hotim-ot-pulera-soedinenij-andrej-borodin-2019","title":{"rendered":"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/6c445191705a4c96939cd094bc457a53.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>In the report, Andrey Borodin will discuss how they considered the experience of scaling PgBouncer when designing the connection pooler. <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/yandex\/odyssey\">Odyssey<\/a><\/noindex>, how they deployed it in production. Additionally, we will discuss what features we would like to see in new versions of the pooler: it is important for us not only to meet our needs but also to develop the community of users. <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/yandex\/odyssey\">Odyssey<\/a><\/noindex>.<\/p>\n<p><noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<p>Video:<\/p>\n<p>\n<center><div class=\"youtube-placeholder\" data-id=\"OUx40ABHFZY\" onclick=\"loadVideo(this)\">\r\n        <img decoding=\"async\" src=\"https:\/\/img.youtube.com\/vi\/OUx40ABHFZY\/hqdefault.jpg\" alt=\"Play video\" loading=\"lazy\" width=\"480\" height=\"360\" style=\"width:100%;height:auto;\">\r\n        <div class=\"play-button\"><\/div>\r\n    <\/div><\/center><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/dd2ea50b72e3d9c4e795aecbf9afdd25.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Hello everyone! My name is Andrey. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/0a2f1880005bec1f61b72fb23b555adc.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>At Yandex, I work on the development of open-source databases. Today, our topic is about connection poolers. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/c18e7c937423d2514faa12e820e78e70.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>If you know how to name a connection pooler in Russian, please let me know. I am eager to find a good technical term that should establish itself in technical literature. <\/p>\n<p><\/p>\n<p>The topic is quite complex because many databases have a built-in connection pooler, and you don't even need to know about it. Some settings, of course, exist everywhere, but it's not the same with Postgres. Meanwhile, there is a talk by Nikolay Samokhvalov at HighLoad++ 2019 about configuring queries in Postgres. I understand that the audience here consists of people who have already perfected their query configurations and are now encountering rarer systemic problems related to networking and resource utilization. At times, this can be quite difficult, as the problems are not obvious.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/89c660dd530575e2938e6bf312b83e95.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Yandex has Postgres. Many Yandex services reside in Yandex.Cloud. We handle several petabytes of data, generating no less than a million queries per second in Postgres. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/288bfa37b9dcd60acd22ba48f0ef8a39.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>We provide a fairly standard cluster for all services \u2013 this includes a primary node, two regular replicas (synchronous and asynchronous), backups, and the scaling of read requests on the replica. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/c249ca55bb387e25a5560324024cc523.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Each cluster node runs Postgres, which besides Postgres and monitoring systems also has a connection pooler installed. The connection pooler is used for fencing and serves its primary purpose. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/0e29be55cc048007db21c80bbb08a9d4.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>What is the primary purpose of a connection pooler? <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/e2fbbd440c2781573cb35deeef358f20.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Postgres adopts a process model for database operations. This means that one connection corresponds to one process, one Postgres backend. In this backend, there are many different caches, which are quite expensive to maintain separately for different connections. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/587498063b1af8fac4a845961c654bc2.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Additionally, in the Postgres code, there is an array called procArray. It contains primary data about network connections. Almost all algorithms that process procArray have linear complexity, traversing the entire array of network connections. This is quite a fast loop, but with a large number of incoming network connections, everything becomes a bit more costly. When things get a little more expensive, you can ultimately pay a very high price for a large number of network connections. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/b534a38d0bfae7a65fc4258155a50280.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>There are three possible approaches:<\/p>\n<p><\/p>\n<ul>\n<li>On the application side. <\/li>\n<li>On the database side. <\/li>\n<li>And in between, i.e., various combinations. <\/li>\n<\/ul>\n<p><\/p>\n<p>Unfortunately, the built-in pooler is currently under development. Friends at PostgreSQL Professional are mainly working on this. When it will be available is hard to predict. Effectively, the architect has two options: application-side pool or proxy pool. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/702527a09e9fc86dd39b7fd69dcf1fc9.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Application-side pool is the simplest way. Almost all client drivers provide a method to represent millions of your connections in the code as a few dozen connections to the database. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/7b66b9e20d22f472ca5ac39f6b9e0ba4.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>The problem arises when you want to scale your backend; you want to deploy it on multiple virtual machines. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/f216fd7a8c01c2b07891e2242c48b06a.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Later, you also realize you have multiple availability zones and data centers. The client-side pooling approach leads to large numbers. Large means around 10,000 connections. That\u2019s the limit for anything that can work normally. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/e5bc5f284fd8ff568bbe16c3895b7ac6.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>When it comes to proxy poolers, there are two poolers that can do a lot of things. They are not just poolers. They are poolers + additional cool functionality. These are: <noindex><a rel=\"nofollow\" href=\"https:\/\/www.pgpool.net\/\">Pgpool<\/a><\/noindex> and <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/CrunchyData\/crunchy-proxy\">Crunchy-Proxy<\/a><\/noindex>. <\/p>\n<p><\/p>\n<p>Unfortunately, this additional functionality is not necessary for everyone. It results in poolers supporting only session pooling, i.e., one incoming client means one outgoing client to the database. <\/p>\n<p><\/p>\n<p>For our tasks, this is not very well suited, which is why we use PgBouncer, which implements transaction pooling, meaning server connections are matched to client connections only for the duration of the transaction. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/e5fedbe14656d2ac2cde8d1878a950e2.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>And under our load, this is true. <strong>But there are a few problems.<\/strong>.<img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/61fd36cadcd9948d624dafa711777307.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Problems start when you want to diagnose a session because all incoming connections are local. They all come from loopback, making it difficult to trace a session. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/36108c4956c410a1b1f286a88bc393d6.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Of course, you can use application_name_add_host. This is a way on the Bouncer side to add an IP address to application_name. However, application_name is set with an additional connection. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/b4cec483aa776f48db7ad3966c3b78e4.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>In this chart, where the yellow line represents real requests and the blue line shows the requests hitting the database. The difference here is exactly the application_name setting, which is needed only for tracing, but it is not free at all. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/c02ea73a6f1a2a4cd6af6c621f321ab4.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>In addition, you cannot limit a single pool in Bouncer, that is, the number of database connections for a specific user, for a specific database. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/3431a463e04106066e2799aead66f571.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>What does this lead to? You have a resource-intensive service written in C++, and nearby there's a small Node service that doesn't do anything severe with the database, but its driver is going haywire. It opens 20,000 connections, and everything else has to wait. Your code is fine. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/d7fa321714dc017b017945dffcf79bc6.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Of course, we wrote a small patch for Bouncer that added this setting, namely, to limit clients by pool. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/d58884fc5ac0f90ff8442f126972157a.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>This could be done on the Postgres side, i.e., limiting database roles by the number of connections.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/8d6ff70db72964ed4eae5eaa47309931.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>But then you lose the ability to understand why you have no connections to the server. PgBouncer does not relay connection errors; it always returns the same information. You can't tell: maybe your password has changed, maybe the database just crashed, or something else is wrong. But there is no diagnosis. If a session cannot be established, you will not find out why. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/cb3048344a94f2953bf403485d28e69f.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>At some point, you look at the application charts and see that the application is not working.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/e67c6680bb9a7f41242af9f9e4920916.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>You check the top processes and see that Bouncer is single-threaded. This is a turning point in the life of the service. You realize that you were preparing to scale the database in a year and a half, and now you need to scale the pooler. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/4c140c4ba6db19cb9939c1148638fb73.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>We came to the conclusion that we need more PgBouncers. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/d369f572a66c16a8917e13393324a644.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/lwn.net\/Articles\/542629\/\">https:\/\/lwn.net\/Articles\/542629\/<\/a><\/noindex><\/p>\n<p><\/p>\n<p>We slightly patched Bouncer. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/97755489a25ebfe38efd56ff897bd8fa.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>And enabled multiple Bouncers to be launched with TCP port reuse. The operating system then automatically distributes incoming TCP connections between them using round-robin.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/ac30d3f067de2a8cd66ad2325c3a3b58.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>This is transparent to clients; everything appears as if you have a single Bouncer, but you have fragmentation of idle connections between the running Bouncers. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/53825f075db00b026c12013a610be456.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>At a certain point, you may notice that these 3 Bouncers are each consuming 100% of their core. You'll need quite a few Bouncers. Why? <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/66c17883a043e157cd7ceab2c2a4e326.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Because you have TLS. You have an encrypted connection. If you benchmark Postgres with and without TLS, you'll find that the number of established connections drops nearly two orders of magnitude with encryption enabled, since the TLS handshake consumes CPU resources. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/6101121ebe136af16e5eb1a484c65d66.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>At the top, you can see quite a few cryptographic functions being performed during the wave of incoming connections. Since our primary can switch between availability zones, a wave of incoming connections is a pretty typical scenario. That is, for some reason, the old primary was unavailable, and all the load was redirected to another data center. They all come trying to say hello to TLS at once. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/c238ac2f511568590dc275e01c192c00.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>And a large number of TLS handshakes may not just greet the Bouncer but could choke it. Due to timeouts, the wave of incoming connections can become persistent. If you try to connect to the database without exponential backoff, they will keep coming again and again as a coherent wave. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/f42d0b210174d4d172254603ae6b834a.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Here's an example of 16 PgBouncers driving 16 cores to 100%.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/8d048d3774c09e5b6a3fb3c7bff62084.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>We have arrived at a cascading PgBouncer. This is the best configuration we can achieve under our load with Bouncer. The external Bouncers handle TCP handshakes, while the internal Bouncers are responsible for actual pooling, to avoid fragmenting external connections excessively.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/3a4ee4ea46d5fe8479a5a7222ee134da.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>In this configuration, a smooth restart is possible. You can restart all 18 Bouncers one by one. However, maintaining such a configuration is quite challenging. System administrators, DevOps, and the people who are truly responsible for this server may not be very pleased with such a scheme. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/5291fe67dbe02036f3ff8e98bdd84d1b.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>It might seem that we could promote all our improvements to open source, but Bouncer is not very well supported. For instance, the ability to run multiple PgBouncers on the same port was committed a month ago. The pull request for this feature was submitted several years ago. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/2059d7f49649d136249103db4aa3ec19.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/www.postgresql.org\/docs\/current\/libpq-cancel.html\">https:\/\/www.postgresql.org\/docs\/current\/libpq-cancel.html<\/a><\/noindex><\/p>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/pgbouncer\/pgbouncer\/pull\/79\">https:\/\/github.com\/pgbouncer\/pgbouncer\/pull\/79<\/a><\/noindex><\/p>\n<p><\/p>\n<p>Or another example. In Postgres, you can cancel a running query by sending a secret over another connection without unnecessary authentication. However, some clients simply send a TCP reset, i.e., they sever the network connection. What will the Bouncer do in this case? It will do nothing. It will continue executing the query. If you have an enormous number of connections that have overloaded the database with small queries, then simply severing the connection from Bouncer will not be enough; you also need to terminate those queries that are running in the database. <\/p>\n<p><\/p>\n<p>This has been patched, and this issue has still not been merged into the upstream Bouncer. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/a9695b6d9e640a5543dc73429eb0050b.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>And so we came to the conclusion that we need our own connection pooler that will evolve, be patched, allow us to quickly fix problems, and, of course, should be multithreaded. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/e755cd9b06a004f0eced1dc12fd3a6fb.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>We set multithreading as our primary objective. We need to handle a wave of incoming TLS connections effectively. <\/p>\n<p><\/p>\n<p>To achieve this, we had to develop a separate library called Machinarium, which is designed to describe machine states of a network connection as sequential code. If you look at the source code of libpq, you'll find quite complex calls that can return a result and say, \"Call me back later. I'm currently busy with IO, but once that's done, I have CPU tasks to handle.\" This is a multi-layered scheme. Network interactions are usually described by a state machine. There are many rules such as \"If I previously received a packet header of size N, I am now expecting N bytes,\" and \"If I sent a SYNC packet, I am now waiting for a packet with the result metadata.\" This results in quite difficult and counterintuitive code, as if a maze were transformed into a linear unfolding. We designed it so that instead of a state machine, the programmer describes the primary interaction path in the form of regular imperative code. However, in this imperative code, you need to insert points where the execution sequence must pause while waiting for data from the network, passing the execution context to another coroutine (green thread). This approach is similar to recording the most expected path in a maze sequentially and then adding branches to it. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/a6bfb4b11961c7db3a7c7184674e3bc2.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>In the end, we have a single thread that performs TCP accept and uses round-robin to distribute the TPC connection among multiple workers. <\/p>\n<p><\/p>\n<p>At the same time, each client connection always operates on one processor. This makes it cache-friendly. <\/p>\n<p><\/p>\n<p>Additionally, we improved the collection of small packets into a larger packet to unload the system TCP stack.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/7d740c23baecdd2f993c83cd54a0a8e1.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Moreover, we enhanced transaction pooling in the sense that Odyssey, with the right configuration, can send CANCEL and ROLLBACK in the event of a network connection drop, meaning that if no one is waiting for the request, Odyssey will instruct the database not to attempt to execute that request, which could waste precious resources.<\/p>\n<p><\/p>\n<p>Whenever possible, we maintain connections for the same client. This prevents the need to reinstall application_name_add_host. If feasible, we avoid additional reinstallation of parameters required for diagnostics. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/afb2fb7fb16d65c9ea73a8978d1eb83c.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>We operate in the interests of Yandex.Cloud. If you are using managed PostgreSQL and have a connection pooler installed, you can create logical replication outwards, meaning you can move away from us if you wish, using logical replication. The Bouncer will not send out the logical replication stream. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/c53defc92ebd8f3bec57ce64d97b9f72.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>This is an example of setting up logical replication. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/a37d9d1abf288d17fa646b642e8b62ab.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Additionally, we support physical replication outwards. In the Cloud, this is, of course, impossible, because then your cluster would reveal too much information about itself. However, in your installations, if you require physical replication through the connection pooler in Odyssey, it is possible. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/572934ce5b08115e57ab4b55d2153c6d.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Odyssey is fully compatible with PgBouncer monitoring. We have a similar console that executes almost all the same commands. If something is missing, please send us a pull request or at least an issue on GitHub, and we will work on adding the needed commands. But the main functionality of the PgBouncer console is already available in ours. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/451dd798fb3523a7a174ebfe00a14bc5.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>And, of course, we have error forwarding. We will return the error reported by the database. You will receive information about why you are not accessing the database rather than just that you are not. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/14b4cb0efa33a2658dfc528349a5382f.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>This feature can be disabled if you require 100% compatibility with PgBouncer. We can behave just like Bouncer, just in case. <\/p>\n<p><\/p>\n<p><strong>Development<\/strong><\/p>\n<p><\/p>\n<p>A few words about the source code of Odyssey. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/6055d5ec9676c331a83592916a6a292f.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/yandex\/odyssey\/pull\/66\">https:\/\/github.com\/yandex\/odyssey\/pull\/66<\/a><\/noindex><\/p>\n<p><\/p>\n<p>For example, there are commands like \"Pause \/ Resume\". They are typically used for updating the database. If you need to update Postgres, you can pause it in the connection pooler, perform a pg_upgrade, and then resume it. From the client's perspective, it will just seem like the database was lagging. This functionality was brought to us by members of the community. It\u2019s not merged yet, but it will be soon. (Already merged)<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/d2f7c57e0ae3e466ec2a701bbdb8eb3f.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/yandex\/odyssey\/pull\/73\">https:\/\/github.com\/yandex\/odyssey\/pull\/73<\/a><\/noindex> \u2014 already merged<\/p>\n<p><\/p>\n<p>Moreover, one of the new features in PgBouncer is the support for SCRAM Authentication, brought to us by someone who doesn't work at Yandex.Cloud. Both of these are complex functionalities and quite important. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/f39346a543c88d17728233d05c2dff19.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Therefore, I want to explain what Odyssey is made of, in case you want to write some code as well. <\/p>\n<p><\/p>\n<p>You have the base Odyssey, which relies on two main libraries. The Kiwi library is the implementation of the Postgres messaging protocol. That is, native proto 3 in Postgres is the standard messages that frontends and backends can exchange. These are implemented in the Kiwi library.<\/p>\n<p><\/p>\n<p>The Machinarium library is the library for stream implementation. A small fragment of this Machinarium is written in assembly. But don\u2019t worry, it's only 15 lines long. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/cd18f250af50eabd53536b2c0d7f12b5.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>The architecture of Odyssey. There is a main machine running coroutines. This machine handles accepting incoming TCP connections and distributing them across workers. <\/p>\n<p><\/p>\n<p>Within a single worker, multiple clients can be handled. Additionally, the main thread runs the console and manages cron tasks for removing connections that are no longer needed in the pool.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/7072fb20f406f2ee5788542860ccdf50.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>For testing Odyssey, we use the standard set of Postgres tests. We simply run install-check through Bouncer and through Odyssey, yielding a null div. There are several tests related to date formatting that do not pass identically in Bouncer and Odyssey.<\/p>\n<p><\/p>\n<p>Additionally, there are many drivers that have their own testing. We use their tests for testing Odyssey.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/fb01cc9a0e9724ddcd3cc3d088afb182.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Furthermore, due to our cascading configuration, we have to test various combinations: Postgres + Odyssey, PgBouncer + Odyssey, Odyssey + Odyssey to ensure that if Odyssey appears in any part of the cascade, it continues to work as we expect. <\/p>\n<p><\/p>\n<p><strong>Troubles<\/strong><\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/25855b691180bca083025b9e8b611c09.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>We use Odyssey in production. It wouldn't be fair to say that everything just works. Yes, that is true, but not always. For instance, in production, everything seemed to work fine until our friends from PostgreSQL Professional pointed out that we had a memory leak. They were right, and we fixed it. But that was just one example. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/e638d88397b32b1ca0b74c9c1b905f81.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Later, we discovered that there are incoming TLS connections and outgoing TLS connections in the connection pooler. Both client certificates and server certificates are needed for these connections.<\/p>\n<p><\/p>\n<p>The server certificates from Bouncer and Odyssey can read from their pcache, but client certificates do not need to be re-read from pcache because our scalable Odyssey ultimately runs into the system performance limitations of reading that certificate. This was unexpected for us, as the problem did not appear immediately. Initially, it scaled linearly, but after 20,000 simultaneous incoming connections, this issue manifested.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/6cff094cd59a990e448b82fa0b1572b7.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Pluggable Authentication Method is the ability to authenticate using built-in Linux mechanisms. In PgBouncer, it is implemented such that there is a separate thread waiting for a response from PAM, and there is the main PgBouncer thread that handles the current connection and can ask them to wait in the PAM thread. <\/p>\n<p><\/p>\n<p>We decided not to implement this for one simple reason. We have many threads. Why do we need this?<\/p>\n<p><\/p>\n<p>Ultimately, this can create issues where, if you have PAM authentication and non-PAM authentication, a large wave of PAM authentication can significantly delay non-PAM authentication. This is one of those things we haven't addressed. But if you want to fix it, you can look into that. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/c7bd9e9980ff7298b30a59c130f03dbb.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Another pitfall was that we have one thread that accepts all incoming connections. It then hands them off to a worker pool, where the TLS handshake occurs.<\/p>\n<p><\/p>\n<p>As a result, if you have a coherent wave of 20,000 network connections, they will all be accepted. And on the client side, libpq will start the timeout countdown. By default, it seems set to 3 seconds. <\/p>\n<p><\/p>\n<p>If they cannot all access the database simultaneously, then they cannot access the database because all of this could be covered by a non-exponential retry. <\/p>\n<p><\/p>\n<p>We came to the point where we copied the scheme from PgBouncer, implementing throttling of the number of TCP connections to which we accept. <\/p>\n<p><\/p>\n<p>If we see that we are accepting connections and they ultimately don\u2019t manage to handshake in time, we queue them so that they don\u2019t consume CPU resources. This means that a simultaneous handshake may not occur for all connections that arrived. But at least someone will access the database, even if the load is quite high.<\/p>\n<p><\/p>\n<p><strong>Roadmap<\/strong><\/p>\n<p><\/p>\n<p>What would we like to see in the future in Odyssey? What are we ready to develop ourselves and what do we expect from the community?<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/4719437d80b33efc3da6572af9a4dedb.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p><strong>As of August 2019.<\/strong><\/p>\n<p><\/p>\n<p>This is what the Odyssey roadmap looked like in August:<\/p>\n<p><\/p>\n<ul>\n<li>We wanted SCRAM and PAM authentication.<\/li>\n<li>We wanted forward read-only queries to standby. <\/li>\n<li>We would like an online restart. <\/li>\n<li>And the ability to pause the server. <\/li>\n<\/ul>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/455c92f92df826257c2c57dc2b034e22.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Half of this roadmap has been completed, and not by us. And that\u2019s good. So let\u2019s discuss what remains and add more. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/4a1daafbfe8d65ba0dd3e1ebdae8dd94.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/yandex\/odyssey\/issues\/12\">As for forwarding read-only queries to standby<\/a><\/noindex>? \u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0440\u0435\u043f\u043b\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0435\u0437 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u0440\u0435\u0442\u044c \u0432\u043e\u0437\u0434\u0443\u0445. \u041e\u043d\u0438 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f failover \u0438 switchover. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0432 \u043e\u0434\u043d\u043e\u043c \u0438\u0437 \u0434\u0430\u0442\u0430-\u0446\u0435\u043d\u0442\u0440\u0435 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0438\u0445 \u0437\u0430\u043d\u044f\u0442\u044c \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u043e\u0439. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0435 \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u044b, \u0442\u0443 \u0436\u0435 \u0441\u0430\u043c\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0438\u043d\u0430\u0447\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0440\u0435\u043f\u043b\u0438\u043a\u0430\u0446\u0438\u044f.<\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/0873cffd4f1ae15d9ffa6d080671051b.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>In principle, in Postgres, starting from version 10, there is an option when connecting to specify session_attrs as well. In the connection, you can list all database hosts and state the purpose of accessing the database: to write or to read only. The driver will then select the first host from the list that meets the session_attrs requirements. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/0693d1327fe5826502a01c21d05d5b4c.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>But the problem with this approach is that it doesn\u2019t control replication lag. You might have a replica that is lagging for an unacceptable amount of time for your service. In order to fully support read queries on the replica, we need to ensure that Odyssey can refrain from operating when reading is not possible. <\/p>\n<p><\/p>\n<p>Odyssey should periodically check the database and inquire about the replication distance from the primary. If it reaches a critical value, new queries should be denied, informing the client that they need to re-initiate connections and possibly select another host for queries. This will allow the database to recover the replication lag faster and return to responding to queries. <\/p>\n<p><\/p>\n<p>It's difficult to specify a timeline for implementation since this is open source. However, I hope it won't take 2.5 years like for my colleagues at PgBouncer. I would like to see this functionality in Odyssey. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/4ec3cd2ff7b2298927cccfe8e0ba890a.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/yandex\/odyssey\/issues\/16\">People in the community have been asking about support for prepared statements.<\/a><\/noindex>You can now create a prepared statement in two ways. First, you can execute the SQL command, namely \"prepared.\" To understand this SQL command, we need to learn to understand SQL on the Bouncer side. This would be overkill since we need a complete parser. We can't parse every SQL command. <\/p>\n<p><\/p>\n<p>However, there is a prepared statement at the message protocol level in proto3. This is when the information about creating a prepared statement comes in a structured form. We could support the understanding that, on some server connection, the client requested to create prepared statements. And even if the transaction is closed, we still need to maintain the coherence between the server and the client. <\/p>\n<p><\/p>\n<p>But there is a divergence in the dialogue because someone is talking about understanding which prepared statements the client created and separating the server connection among all clients that established that server connection, i.e., those who created such prepared statements. <\/p>\n<p><\/p>\n<p>Andres Freund said that if a client comes to you that has already created such a prepared statement in another server connection, you should create it for them. However, it seems a bit wrong to execute queries in the database instead of the client, but from the perspective of a developer writing a protocol for interacting with the database, it would be convenient if they were simply given a network connection with that prepared query. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/cd56b3ad015195d86a64e52be365b16a.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>And another feature that we need to implement. We currently have monitoring compatible with PgBouncer. We can return the average execution time of a query. But the average time is like the average temperature in a hospital: some are cold, some are warm\u2014on average, everyone is healthy. That's not true. <\/p>\n<p><\/p>\n<p>We need to implement support for percentiles that would indicate that there are slow queries consuming resources and make the monitoring more acceptable. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/6f285f3eb0d79e7f25d42f0e792b85b1.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>Most importantly, we want version 1.0 (Version 1.1 has already been released). The issue is that Odyssey is currently in version 1.0rc, i.e., release candidate. All the issues I listed were fixed with that version, except for the memory leak. <\/p>\n<p><\/p>\n<p>What will version 1.0 mean for us? We are rolling out Odyssey to our databases. It is already functioning on our infrastructure, but when it reaches the milestone of 1,000,000 requests per second, we can officially say that this is the release version, which we can call 1.0. <\/p>\n<p><\/p>\n<p>Some members of the community have requested that version 1.0 also include pause and SCRAM. However, this would mean that we would need to release the next version in production because neither SCRAM nor pause has been merged yet. But, most likely, this issue will be resolved fairly quickly. <\/p>\n<p><\/p>\n<p><img decoding=\"async\" alt=\"\ud83e\udd47Windows 10 + Linux. Setting up the KDE Plasma GUI for Ubuntu 20.04 in WSL2. Step-by-step guide | ProHoster\" src=\"\/wp-content\/uploads\/2020\/10\/2f50de9f51f653a7396965239bd545e1.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<p><\/p>\n<p>I am awaiting your pull requests. I would also like to hear about any problems you are having with Bouncer. Let\u2019s discuss them. Perhaps we can implement some features that you need. <\/p>\n<p><\/p>\n<p>This concludes my part; I would like to hear from you. Thank you!<\/p>\n<p><\/p>\n<p>Questions<\/p>\n<p><\/p>\n<p><em>If I set my application_name, will it be properly passed, including in transaction pooling in Odyssey?<\/em><\/p>\n<p><\/p>\n<p>In Odyssey or in Bouncer?<\/p>\n<p><\/p>\n<p><em>In Odyssey. It is passed in Bouncer.<\/em> <\/p>\n<p><\/p>\n<p>We will set it. <\/p>\n<p><\/p>\n<p><em>And if my actual connection jumps across other connections, will it still get passed?<\/em><\/p>\n<p><\/p>\n<p>We will set all parameters listed. I can't say if application_name is included in that list. I think I\u2019ve seen it there. We will apply all the same parameters. One request will set everything that was established by the client at startup. <\/p>\n<p><\/p>\n<p><em>Thank you, Andrey, for the presentation! Great presentation! I\u2019m glad that Odyssey is developing faster and faster every minute. I wish you continued success. We have already contacted you with a request for a multi data-source connection, so that Odyssey can connect simultaneously to different databases, i.e. master-slave, and then automatically reconnect to a new master after failover.<\/em> <\/p>\n<p><\/p>\n<p>Yes, I seem to remember this discussion. Currently, there are several storages. But there is no switching between them. We need to poll the server on our side to check if it is still alive and to understand that a failover has occurred, and who will call pg_recovery. I have a standard way to determine that we are not connected to the master. And we must somehow deduce it from errors or what? That is, the idea is interesting and being discussed. Write more comments. If you have any hands-on people who know C, that would be great. <\/p>\n<p><\/p>\n<p>The issue of scaling through replicas is also of interest to us because we want to make the adoption of replicated clusters as simple as possible for application developers. However, we would like more comments on how exactly to do this and how to do it well. <\/p>\n<p><\/p>\n<p><em>This question is also about replicas. It turns out that you have a master and several replicas. Clearly, connections go to the replica less frequently than to the master since there may be differences. You mentioned that the difference in data could be such that it won't meet your business needs, and you won't access it until it is fully replicated. Meanwhile, if you haven't accessed it for a long time and then start doing so, the needed data may not be readily available. This means that if we constantly access the master, its cache is warm, but the replica's cache lags slightly.<\/em> <\/p>\n<p><\/p>\n<p>Yes, that's true. The pcache won't contain the data blocks you want; the real cache won't have the information about the tables you need; and the plans won't have parsed queries\u2014essentially, there will be nothing. <\/p>\n<p><\/p>\n<p><em>And when you have a cluster and add a new replica, while it starts up, everything is poor in it, meaning it is building up its cache.<\/em> <\/p>\n<p><\/p>\n<p>I understand the idea. The correct approach would be to initially run a small percentage of queries on the replica to warm up the cache. Roughly speaking, we have a condition that we must not lag more than 10 seconds behind the master. And this condition should not be enabled in one go, but gradually for certain clients. <\/p>\n<p><\/p>\n<p><em>Yes, increase the weight.<\/em><\/p>\n<p><\/p>\n<p>That's a good idea. But first, we need to implement this shutdown. We need to turn it off first, and then we'll think about how to turn it back on. This is a great feature for a smooth startup.<\/p>\n<p><\/p>\n<p><em>There is such an option in nginx. <code>slowly start<\/code> in the cluster for the server. And it gradually increases the load.<\/em> <\/p>\n<p><\/p>\n<p>Yes, great idea, we'll try it when we get to that.<\/p>\n<p>Source: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/post\/522734\/\">habr.com<\/a> <\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0412 \u0434\u043e\u043a\u043b\u0430\u0434\u0435 \u0410\u043d\u0434\u0440\u0435\u0439 \u0411\u043e\u0440\u043e\u0434\u0438\u043d \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0435\u0442, \u043a\u0430\u043a \u043e\u043d\u0438 \u0443\u0447\u043b\u0438 \u043e\u043f\u044b\u0442 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f PgBouncer \u043f\u0440\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0443\u043b\u0435\u0440\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439 Odyssey, \u043a\u0430\u043a \u0432\u044b\u043a\u0430\u0442\u044b\u0432\u0430\u043b\u0438 \u0435\u0433\u043e \u0432 production. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u0431\u0441\u0443\u0434\u0438\u043c \u043a\u0430\u043a\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0443\u043b\u0435\u0440\u0430 \u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0431\u044b \u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u043d\u043e\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445: \u043d\u0430\u043c \u0432\u0430\u0436\u043d\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u041e\u0434\u0438\u0441\u0441\u0435\u044f. \u0412\u0438\u0434\u0435\u043e: \u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! \u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0410\u043d\u0434\u0440\u0435\u0439. \u0412 \u042f\u043d\u0434\u0435\u043a\u0441\u0435 \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":96516,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-96515","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2 - aioseo.com -->\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Yuri Gagarin\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/odyssey-roadmap-chto-eshhyo-my-hotim-ot-pulera-soedinenij-andrej-borodin-2019\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"\ud83e\udd47Odyssey roadmap: \u0447\u0442\u043e \u0435\u0449\u0451 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442 \u043f\u0443\u043b\u0435\u0440\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439. \u0410\u043d\u0434\u0440\u0435\u0439 \u0411\u043e\u0440\u043e\u0434\u0438\u043d (2019) | ProHoster\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/odyssey-roadmap-chto-eshhyo-my-hotim-ot-pulera-soedinenij-andrej-borodin-2019\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg\" \/>\n\t\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t\t<meta property=\"og:image:height\" content=\"350\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2020-10-12T17:43:02+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-10-12T17:43:02+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/prohoster\" \/>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"\ud83e\udd47Odyssey roadmap: what more do we want from the connection pooler. Andrey Borodin (2019) | ProHoster","description":"","canonical_url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/odyssey-roadmap-chto-eshhyo-my-hotim-ot-pulera-soedinenij-andrej-borodin-2019","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"en_US","og:site_name":"ProHoster | \u041a\u0443\u043f\u0438\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0434\u043b\u044f \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0437\u0430\u0449\u0438\u0442\u043e\u0439 \u043e\u0442 DDoS, VPS VDS \u0441\u0435\u0440\u0432\u0435\u0440\u044b","og:type":"article","og:title":"\ud83e\udd47Odyssey roadmap: \u0447\u0442\u043e \u0435\u0449\u0451 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043e\u0442 \u043f\u0443\u043b\u0435\u0440\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439. \u0410\u043d\u0434\u0440\u0435\u0439 \u0411\u043e\u0440\u043e\u0434\u0438\u043d (2019) | ProHoster","og:url":"https:\/\/prohoster.info\/en\/blog\/administrirovanie\/odyssey-roadmap-chto-eshhyo-my-hotim-ot-pulera-soedinenij-andrej-borodin-2019","og:image":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:secure_url":"https:\/\/prohoster.info\/wp-content\/uploads\/2021\/11\/logo-350.jpg","og:image:width":350,"og:image:height":350,"article:published_time":"2020-10-12T17:43:02+00:00","article:modified_time":"2020-10-12T17:43:02+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"96515","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"seo_analyzer_scan_date":null,"breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 10:41:30","updated":"2022-10-01 00:02:14","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/96515","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/comments?post=96515"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/posts\/96515\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media\/96516"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/media?parent=96515"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/categories?post=96515"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/en\/wp-json\/wp\/v2\/tags?post=96515"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}