{"id":53530,"date":"2019-12-04T00:00:00","date_gmt":"2019-12-03T21:00:00","guid":{"rendered":"https:\/\/prohoster.info\/blog\/blog_prohoster\/uskoryaem-php-konnektory-dlya-tarantool-s-pomoshhyu-async-swoole-i-parallel"},"modified":"2020-02-18T14:01:26","modified_gmt":"2020-02-18T11:01:26","slug":"uskoryaem-php-konnektory-dlya-tarantool-s-pomoshhyu-async-swoole-i-parallel","status":"publish","type":"post","link":"https:\/\/prohoster.info\/hu\/blog\/administrirovanie\/uskoryaem-php-konnektory-dlya-tarantool-s-pomoshhyu-async-swoole-i-parallel","title":{"rendered":"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel","gt_translate_keys":[{"key":"rendered","format":"text"}]},"content":{"rendered":"<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/a4bfc8a3f7f7de0298623b1bf9dcfc54.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n<br \/>\nA PHP \u00f6kosziszt\u00e9m\u00e1j\u00e1ban jelenleg k\u00e9t csatlakoz\u00f3 \u00e1ll rendelkez\u00e9sre a Tarantool szerverrel val\u00f3 munk\u00e1hoz - ez a hivatalos PECL kiterjeszt\u00e9s <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/tarantool\/tarantool-php\">tarantool\/tarantool-php<\/a><\/noindex>, amely C nyelven k\u00e9sz\u00fclt, \u00e9s <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/tarantool-php\/client\">tarantool-php\/client<\/a><\/noindex>, amely PHP nyelven \u00edr\u00f3dott. \u00c9n vagyok az ut\u00f3bbi szerz\u0151je.<\/p>\n<p>Ebben a cikkben szeretn\u00e9m megosztani a k\u00e9t k\u00f6nyvt\u00e1r teljes\u00edtm\u00e9nytesztel\u00e9s\u00e9nek eredm\u00e9nyeit, \u00e9s megmutatni, hogyan lehet minim\u00e1lis k\u00f3dm\u00f3dos\u00edt\u00e1sokkal 3-5%-os teljes\u00edtm\u00e9nyn\u00f6veked\u00e9st el\u00e9rni (<i>szintetikus teszteken!<\/i>).<br \/>\n<noindex><a rel=\"nofollow\" name=\"habracut\"><\/a><\/noindex><\/p>\n<h2>Mit fogunk tesztelni?<\/h2>\n<p>\nA fent eml\u00edtett <i>szinkron<\/i> csatlakoz\u00f3kat fogjuk tesztelni, amelyeket aszinkron, p\u00e1rhuzamosan \u00e9s aszinkron-p\u00e1rhuzamosan futtatunk. \ud83d\ude42 Ezenk\u00edv\u00fcl nem akarjuk meg\u00e9rinteni maguknak a csatlakoz\u00f3knak a k\u00f3dj\u00e1t. Jelenleg el\u00e9rhet\u0151 n\u00e9h\u00e1ny kiterjeszt\u00e9s, amelyek lehet\u0151v\u00e9 teszik a k\u00edv\u00e1nt eredm\u00e9ny el\u00e9r\u00e9s\u00e9t:<\/p>\n<ul>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/swoole\/swoole-src\">Swoole<\/a><\/noindex> \u2015 egy magas teljes\u00edtm\u00e9ny\u0171 aszinkron keretrendszer PHP-hez. Olyan internetes \u00f3ri\u00e1sok haszn\u00e1lj\u00e1k, mint az Alibaba \u00e9s a Baidu. A 4.1.0-\u00e1s verzi\u00f3t\u00f3l kezdve egy var\u00e1zslatos met\u00f3dus jelent meg <i>SwooleRuntime::enableCoroutine()<\/i>, amely lehet\u0151v\u00e9 teszi, hogy \"egy k\u00f3dsorral \u00e1talak\u00edtsuk a szinkron h\u00e1l\u00f3zati k\u00f6nyvt\u00e1rakat PHP-ben aszinkronokk\u00e1\".\n<\/li>\n<li>Async \u2015 nemr\u00e9giben m\u00e9g \u00edg\u00e9retes kiterjeszt\u00e9s volt aszinkron munk\u00e1ra PHP-ben. Mi\u00e9rt nemr\u00e9giben? Sajnos, sz\u00e1momra ismeretlen okb\u00f3l az \u00edr\u00f3 t\u00f6r\u00f6lte a repozit\u00f3riumot, \u00e9s a projekt j\u00f6v\u0151je hom\u00e1lyos. Haszn\u00e1lnunk kell <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/dreamsxin\/ext-async\">egy<\/a><\/noindex> forkb\u00f3l. Ahogy a Swoole, ez a kiterjeszt\u00e9s lehet\u0151v\u00e9 teszi, hogy k\u00f6nnyed\u00e9n \u00e1tv\u00e1ltsunk a szinkron m\u00f3dokr\u00f3l aszinkronra az\u00e1ltal, hogy a TCP \u00e9s TLS sz\u00e1lak standard megval\u00f3s\u00edt\u00e1sait az aszinkron verzi\u00f3ikra cser\u00e9lj\u00fck. Ezt a &#171; lehet\u0151s\u00e9ggel v\u00e9gezz\u00fck<i>async.tcp = 1<\/i>A &#171;ALTER TABLE&#187; \u00e9s &#171;RENAME TABLE&#187; m\u0171veletekben t\u00e1mogat\u00e1sra ker\u00fclt a &#171;IF EXISTS&#187; felt\u00e9tel, amely lehet\u0151v\u00e9 teszi az oper\u00e1ci\u00f3 v\u00e9grehajt\u00e1s\u00e1t a t\u00e1bla l\u00e9tez\u00e9se eset\u00e9n.\n<\/li>\n<li><noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/krakjoe\/parallel\">Parallel<\/a><\/noindex> \u2015 egy viszonylag \u00faj kiterjeszt\u00e9s a j\u00f3l ismert Joe Watkins-t\u00f3l, aki olyan k\u00f6nyvt\u00e1rakat \u00edrt, mint a phpdbg, apcu, pthreads, pcov, uopz. A kiterjeszt\u00e9s API-t biztos\u00edt a p\u00e1rhuzamos munk\u00e1hoz PHP-ben, \u00e9s \u00fagy van pozicion\u00e1lva, mint a pthreads helyettes\u00edt\u0151je. A k\u00f6nyvt\u00e1r jelent\u0151s korl\u00e1toz\u00e1sa, hogy csak a ZTS (Zend Thread Safe) verzi\u00f3val m\u0171k\u00f6dik PHP-ben.\n<\/li>\n<\/ul>\n<p><\/p>\n<h2>Hogyan fogjuk tesztelni?<\/h2>\n<p>\nInd\u00edtsunk egy Tarantool p\u00e9ld\u00e1nyt el\u0151zetes \u00edr\u00e1si napl\u00f3z\u00e1s n\u00e9lk\u00fcl (<i>wal_mode = none<\/i>), \u00e9s megn\u00f6velt h\u00e1l\u00f3zati pufferral (<i>readahead = 1 * 1024 * 1024<\/i>). Az els\u0151 opci\u00f3 kiz\u00e1rja a lemezzel val\u00f3 munk\u00e1t, a m\u00e1sodik lehet\u0151v\u00e9 teszi, hogy t\u00f6bb lek\u00e9rdez\u00e9st olvassunk ki a rendszer puffer\u00e9b\u0151l, ez\u00e1ltal minimaliz\u00e1lva a rendszerh\u00edv\u00e1sok sz\u00e1m\u00e1t.<\/p>\n<p>A benchmark that works with data (insertion, deletion, reading, etc.) will create (or recreate) a memtx space before the benchmark starts, where the values of the primary index are generated by a sequence of ordered integers.<br \/>\nThe DDL of the space looks like this:<\/p>\n<pre><code class=\"lua\">space = box.schema.space.create(config.space_name, {id = config.space_id, temporary = true})\nspace:create_index('primary', {type = 'tree', parts = {1, 'unsigned'}, sequence = true})\nspace:format({{name = 'id', type = 'unsigned'}, {name = 'name', type = 'string', is_nullable = false}})<\/code><\/pre>\n<p>\nIf necessary, before starting the benchmark, the space is filled with 10,000 tuples of the form<\/p>\n<pre><code class=\"lua\">{id, \"tupl\u0435_\"}<\/code><\/pre>\n<p>\nAccess to the tuples is done by a random key value.<\/p>\n<p>The benchmark itself is a single request to the server, executed 10,000 times (revolutions), which are in turn executed in iterations. The iterations are repeated until all time deviations among 5 iterations fall within an acceptable margin of error of 3%*. After that, the average result is taken. There is a 1-second pause between iterations to prevent the CPU from throttling. The Lua garbage collector is disabled before each iteration and forced to run after it is completed. The PHP process is launched only with the extensions necessary for the benchmark, with output buffering enabled and garbage collection disabled.<\/p>\n<p><i>* The number of revolutions, iterations, and error threshold can be changed in the benchmark settings.<\/i><\/p>\n<h2>Test environment<\/h2>\n<p>\nAz al\u00e1bb k\u00f6zz\u00e9tett eredm\u00e9nyeket MacBookPro (2015) sz\u00e1m\u00edt\u00f3g\u00e9pen v\u00e9gezt\u00fck, az oper\u00e1ci\u00f3s rendszer \u2013 Fedora 30 (kernel verzi\u00f3 5.3.8-200.fc30.x86_64). A Tarantool Dockerben indult a &#171; param\u00e9terrel<code>--network host\"<\/code>.<\/p>\n<p>Package versions:<\/p>\n<p>Tarantool: 2.3.0-115-g5ba5ed37e<br \/>\nDocker: 19.03.3, build a872fc2f86<br \/>\nPHP: 7.3.11 (cli) (built: Oct 22 2019 08:11:04)<br \/>\ntarantool\/client: 0.6.0<br \/>\nrybakit\/msgpack: 0.6.1<br \/>\next-tarantool: 0.3.2 (+ patch for 7.3)*<br \/>\next-msgpack: 2.0.3<br \/>\next-async: 0.3.0-8c1da46<br \/>\next-swoole: 4.4.12<br \/>\next-parallel: 1.1.3<\/p>\n<p>* <i>Unfortunately, the official connector does not work with PHP version &gt; 7.2. To compile and run the extension on PHP 7.3, a patch had to be used <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/tarantool\/tarantool-php\/pull\/148\/files\">patch<\/a><\/noindex>.<\/i><\/p>\n<h2>Eredm\u00e9nyek<\/h2>\n<p><\/p>\n<h4>Synchronous mode<\/h4>\n<p>\nTarantool\u2019s protocol uses a binary format <noindex><a rel=\"nofollow\" href=\"https:\/\/msgpack.org\/\">MessagePack<\/a><\/noindex> for serializing messages. In the PECL connector, serialization is hidden deep within the library and it is not possible to influence the encoding process from userland code <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/tarantool\/tarantool-php\/issues\/89\">.<\/a><\/noindex>. A tiszta PHP-s csatlakoz\u00f3 szemben testreszab\u00e1si lehet\u0151s\u00e9get biztos\u00edt a k\u00f3dol\u00e1si folyamatban a standard k\u00f3dol\u00f3 kiterjeszt\u00e9s\u00e9nek b\u0151v\u00edt\u00e9s\u00e9vel vagy a saj\u00e1t megval\u00f3s\u00edt\u00e1s haszn\u00e1lat\u00e1val. Alap\u00e9rtelmezetten k\u00e9t k\u00f3dol\u00f3 \u00e9rhet\u0151 el, az egyik alapja a <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/msgpack\/msgpack-php\/\">msgpack\/msgpack-php<\/a><\/noindex> (hivatalos MessagePack PECL kiterjeszt\u00e9s), a m\u00e1sik pedig a <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/rybakit\/msgpack.php\">rybakit\/msgpack<\/a><\/noindex> (tiszt\u00e1n PHP-ban).<\/p>\n<p>A csatlakoz\u00f3k \u00f6sszehasonl\u00edt\u00e1sa el\u0151tt m\u00e9rj\u00fck meg a MessagePack k\u00f3dol\u00f3k teljes\u00edtm\u00e9ny\u00e9t a PHP csatlakoz\u00f3 sz\u00e1m\u00e1ra, \u00e9s a tov\u00e1bbi tesztekben azt fogjuk haszn\u00e1lni, amelyik a legjobb eredm\u00e9nyt mutatja:<\/p>\n<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/a293ec51cb8bf18cb88df2dc276142c4.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nB\u00e1r a PHP verzi\u00f3 (Pure) sebess\u00e9gben elmarad a PECL kiterjeszt\u00e9st\u0151l, a val\u00f3s projektekben mindenk\u00e9ppen azt aj\u00e1nlan\u00e1m haszn\u00e1lni, <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/rybakit\/msgpack.php\">rybakit\/msgpack<\/a><\/noindex>, mert a hivatalos MessagePack kiterjeszt\u00e9sben a form\u00e1tum specifik\u00e1ci\u00f3ja csak r\u00e9szben van megval\u00f3s\u00edtva (p\u00e9ld\u00e1ul nincs t\u00e1mogat\u00e1s a felhaszn\u00e1l\u00f3i adatt\u00edpusokhoz, amely n\u00e9lk\u00fcl nem tudja haszn\u00e1lni a Decimal-t \u2014 az \u00faj adatt\u00edpus, amely a Tarantool 2.3-ban jelent meg) \u00e9s sz\u00e1mos m\u00e1s, <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/msgpack\/msgpack-php\/issues\">probl\u00e9m\u00e1kra<\/a><\/noindex> (bele\u00e9rtve a PHP 7.4-tel kapcsolatos kompatibilit\u00e1si probl\u00e9m\u00e1kat). A projekt eg\u00e9sz\u00e9ben v\u00e9ve elhagyatottnak t\u0171nik.<\/p>\n<p>Teh\u00e1t m\u00e9rj\u00fck meg a csatlakoz\u00f3k teljes\u00edtm\u00e9ny\u00e9t szinkron m\u00f3dban:<\/p>\n<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/d8c5765956c62b927014ec4f26547820.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nAhogy a grafikonon l\u00e1that\u00f3, a PECL csatlakoz\u00f3 (Tarantool) jobb teljes\u00edtm\u00e9nyt mutat a PHP csatlakoz\u00f3val (Client) szemben. De ez nem is meglep\u0151, figyelembe v\u00e9ve, hogy az ut\u00f3bbi, azon k\u00edv\u00fcl, hogy egy lassabb nyelven van megval\u00f3s\u00edtva, tulajdonk\u00e9ppen t\u00f6bb munk\u00e1t v\u00e9gez: minden h\u00edv\u00e1sn\u00e1l \u00faj objektum j\u00f6n l\u00e9tre <i>K\u00e9r\u00e9s<\/i> \u00e9s <i>V\u00e1lasz<\/i> (Select eset\u00e9n \u2014 m\u00e9g a <i>Krit\u00e9riumok<\/i>, Update\/Upsert eset\u00e9n pedig \u2014 <i>M\u0171veletek<\/i>), k\u00fcl\u00f6n entit\u00e1sok <i>Connection<\/i>, <i>Csomagol\u00f3 <\/i>\u00e9s <i>Kezel\u0151<\/i> szint\u00e9n hozz\u00e1adnak egy plusz terhet. Nyilv\u00e1nval\u00f3, hogy a rugalmass\u00e1g\u00e9rt fizetni kell. Ugyanakkor a PHP interpreter \u00e1ltal\u00e1noss\u00e1gban j\u00f3 teljes\u00edtm\u00e9nyt mutat, b\u00e1r van k\u00fcl\u00f6nbs\u00e9g, az elhanyagolhat\u00f3, \u00e9s val\u00f3sz\u00edn\u0171leg m\u00e9g kisebb lesz a PHP 7.4 preloading haszn\u00e1latakor, nem is besz\u00e9lve a PHP 8 JIT-r\u0151l.<\/p>\n<p>Tov\u00e1bb l\u00e9pve. A Tarantool 2.0-ban megjelent az SQL t\u00e1mogat\u00e1s. Pr\u00f3b\u00e1ljuk ki a Select, Insert, Update \u00e9s Delete m\u0171veletek v\u00e9grehajt\u00e1s\u00e1t SQL protokollal, \u00e9s hasonl\u00edtsuk \u00f6ssze az eredm\u00e9nyeket noSQL (binaris) megfelel\u0151ikkel:<\/p>\n<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/cbc61697d9670dc7384c25de3c63c8d5.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nAz SQL eredm\u00e9nyek nem t\u00fal leny\u0171g\u00f6z\u0151ek (eml\u00e9keztetn\u00e9k, hogy m\u00e9g mindig a szinkron m\u00f3dot tesztelj\u00fck). Azonban nem \u00e9rdemesene k\u00e9ts\u00e9gbe esni emiatt, hiszen az SQL t\u00e1mogat\u00e1s tov\u00e1bbra is akt\u00edv fejleszt\u00e9s alatt \u00e1ll (viszonylag nem r\u00e9giben p\u00e9ld\u00e1ul a t\u00e1mogat\u00e1s megjelent <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/tarantool\/tarantool\/commit\/ff2091e09b5a7e9b7aa3f3e996dc7a06189889f3\">el\u0151re elk\u00e9sz\u00edtett utas\u00edt\u00e1sok<\/a><\/noindex>), \u00e9s a lista alapj\u00e1n <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/tarantool\/tarantool\/issues?q=is%3Aissue+is%3Aopen+sql+label%3Aperformance\">probl\u00e9m\u00e1k<\/a><\/noindex>, az SQL motor a j\u00f6v\u0151ben sz\u00e1mos optimaliz\u00e1ci\u00f3ra sz\u00e1m\u00edt.<\/p>\n<h4>Async<\/h4>\n<p>\nNos, n\u00e9zz\u00fck meg most, hogyan tud az Async kiterjeszt\u00e9s seg\u00edteni nek\u00fcnk a fenti eredm\u00e9nyek jav\u00edt\u00e1s\u00e1ban. Aszinkron programok \u00edr\u00e1s\u00e1hoz az API-t korutinok (coroutines) alapj\u00e1n biztos\u00edtja, \u00e9s ezt fogjuk kihaszn\u00e1lni. Tapasztalataink szerint az optim\u00e1lis korutinok sz\u00e1ma a mi k\u00f6rnyezet\u00fcnkben 25:<\/p>\n<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/4ceefef522b3bd91db7327c609ddda09.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nFelosszuk 10,000 m\u0171veletet 25 korutinra, \u00e9s megn\u00e9zz\u00fck, mi t\u00f6rt\u00e9nt:<\/p>\n<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/916e461dfa5d1be08317e3703c267afe.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nA m\u00e1sodpercenk\u00e9nti m\u0171veletek sz\u00e1ma t\u00f6bb mint h\u00e1romszoros\u00e1ra n\u0151tt a k\u00f6vetkez\u0151 eset\u00e9ben: <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/tarantool-php\/client\">tarantool-php\/client<\/a><\/noindex>!<\/p>\n<p>Sajn\u00e1latos m\u00f3don a PECL csatlakoz\u00f3 nem indult el az ext-async-nal.<\/p>\n<p>De mi a helyzet az SQL-lel?<\/p>\n<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/39a0da214b893a217d9ae4eae23c4168.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nAhogy l\u00e1tjuk, aszinkron m\u00f3dban a bin\u00e1ris protokoll \u00e9s az SQL k\u00f6z\u00f6tti k\u00fcl\u00f6nbs\u00e9g a t\u0171r\u00e9si hat\u00e1rokon bel\u00fcl van.<\/p>\n<h4>Swoole<\/h4>\n<p>\n\u00dajra megkeress\u00fck az optim\u00e1lis korutinok sz\u00e1m\u00e1t, most m\u00e1r a Swoole sz\u00e1m\u00e1ra:<br \/>\n<img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/70d5bb26b91b7459e2f0b80a3fab7e06.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nMaradjunk a 25-n\u00e9l. Ism\u00e9telni fogjuk ugyanazt a tr\u00fckk\u00f6t, mint az Async kiterjeszt\u00e9sn\u00e9l \u2013 10,000 m\u0171veletet elosztunk 25 korutin k\u00f6z\u00f6tt. Emellett egy m\u00e1sik tesztet is hozz\u00e1adunk, amelyben az eg\u00e9sz munk\u00e1t 2 folyamatra osztjuk (vagyis minden folyamat 5,000 m\u0171veletet hajt v\u00e9gre 25 korutinban). A folyamatokat a k\u00f6vetkez\u0151 seg\u00edts\u00e9g\u00e9vel fogjuk l\u00e9trehozni: <i>SwooleProcess<\/i>. <\/p>\n<p>Results:<\/p>\n<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/55f55d2661aa43ca3b6641abfff078a6.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nA Swoole egy kicsit alacsonyabb eredm\u00e9nyt mutat egy folyamatban ind\u00edtva, de 2 folyamattal a helyzet dr\u00e1maian megv\u00e1ltozik (a 2-es sz\u00e1m nem v\u00e9letlen\u00fcl lett v\u00e1lasztva, a g\u00e9pem pontosan 2 folyamatn\u00e1l mutatta a legjobb eredm\u00e9nyt).<\/p>\n<p><i>Egy\u00e9bk\u00e9nt az Async kiterjeszt\u00e9sben is van API a folyamatok kezel\u00e9s\u00e9re, de itt nem vettem \u00e9szre semmilyen k\u00fcl\u00f6nbs\u00e9get az egy vagy t\u00f6bb folyamatban futtatott benchmarkok k\u00f6z\u00f6tt (lehet, hogy valamit f\u00e9lre\u00e9rtettem).<\/i><\/p>\n<p>SQL vs bin\u00e1ris protokoll:<\/p>\n<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/dfa56be01ebba25edbec492838112778.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nAhogy az Async eset\u00e9ben is, az aszinkron m\u00f3dban a bin\u00e1ris \u00e9s SQL m\u0171veletek k\u00f6z\u00f6tti k\u00fcl\u00f6nbs\u00e9get kiegyenl\u00edti.<\/p>\n<h4>Parallel<\/h4>\n<p>\nMivel a Parallel kiterjeszt\u00e9s nem a korutinokkal, hanem a sz\u00e1lakkal foglalkozik, m\u00e9rj\u00fck meg az optim\u00e1lis p\u00e1rhuzamos sz\u00e1lak sz\u00e1m\u00e1t:<\/p>\n<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/acc6796d5731b0402ad6323e0f5bf38f.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nEz 16 a g\u00e9pem eset\u00e9ben. Ind\u00edtsuk el a csatlakoz\u00f3k benchmarkjait 16 p\u00e1rhuzamos sz\u00e1lon:<\/p>\n<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/03210b70f15e445fdd311a17c1034290.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\nAhogy l\u00e1tjuk, az eredm\u00e9ny m\u00e9g jobban teljes\u00edt, mint az aszinkron kiterjeszt\u00e9sekkel (kiv\u00e9ve a Swoole-t, amely 2 folyamatban fut). Ne feledj\u00fck, hogy a PECL csatlakoz\u00f3 hely\u00e9n az Update \u00e9s Upsert m\u0171veletekn\u00e9l \u00fcres a hely. Ennek oka, hogy ezek a m\u0171veletek hib\u00e1val megszakadtak - nem tudom, hogy az ext-parallel, az ext-tarantool vagy mindkett\u0151 hib\u00e1j\u00e1b\u00f3l ad\u00f3dik.<\/p>\n<p>Most hasonl\u00edtsuk \u00f6ssze az SQL teljes\u00edtm\u00e9ny\u00e9t:<\/p>\n<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/4be3025b424ad6485dc96968ce224bf5.jpg\" style=\"display:block;margin: 0 auto;\" \/><br \/>\n\u00c9szrevette a hasonl\u00f3s\u00e1got a szinkron m\u00f3dban fut\u00f3 csatlakoz\u00f3k grafikonj\u00e1val?<\/p>\n<h4>Mind egy\u00fctt<\/h4>\n<p>\nV\u00e9g\u00fcl \u00f6sszegezz\u00fck az \u00f6sszes eredm\u00e9nyt egy grafikonra, hogy l\u00e1ssuk a tesztelt kiterjeszt\u00e9sek \u00e1ltal\u00e1nos k\u00e9p\u00e9t. A grafikonra csak egy \u00faj tesztet adunk hozz\u00e1, amit m\u00e9g nem v\u00e9gezt\u00fcnk el - egyes\u00edtj\u00fck az Async korutinokat p\u00e1rhuzamosan a Parallel* seg\u00edts\u00e9g\u00e9vel. Az eml\u00edtett kiterjeszt\u00e9sek integr\u00e1l\u00e1sa m\u00e1r <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/krakjoe\/parallel\/issues\/25\">t\u00e1rgyalt\u00e1k<\/a><\/noindex> a szerz\u0151k, de konszenzus m\u00e9g mindig nem sz\u00fcletett, ezt magunknak kell megoldanunk. <\/p>\n<p><i>* A Swoole korutinok Parallel-lel val\u00f3 ind\u00edt\u00e1sa nem m\u0171k\u00f6d\u00f6tt, \u00fagy t\u0171nik, hogy ezek a kiterjeszt\u00e9sek nem kompatibilisek.<\/i><\/p>\n<p>Teh\u00e1t, a v\u00e9gs\u0151 eredm\u00e9nyek:<\/p>\n<p><img decoding=\"async\" alt=\"PHP-kapcsol\u00f3k gyors\u00edt\u00e1sa Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel\" src=\"\/wp-content\/uploads\/2019\/12\/85478d9dd5d8bd166f4aa91963c1af95.jpg\" style=\"display:block;margin: 0 auto;\" \/><\/p>\n<h2>\u00d6sszegz\u00e9sk\u00e9nt<\/h2>\n<p>\nSzerintem az eredm\u00e9nyek igaz\u00e1n figyelemre m\u00e9lt\u00f3ak, \u00e9s valami\u00e9rt biztos vagyok benne, hogy ez m\u00e9g nem a v\u00e9gs\u0151 hat\u00e1r! Hogy sz\u00fcks\u00e9g van-e erre egy val\u00f3s projektben, csakis rajtatok m\u00falik, annyit mondhatok, hogy sz\u00e1momra ez egy \u00e9rdekes k\u00eds\u00e9rlet volt, amely lehet\u0151v\u00e9 tette, hogy felm\u00e9rjem, mennyit lehet 'kicsikarni' a szinkron TCP-kapcsol\u00f3b\u00f3l minim\u00e1lis er\u0151fesz\u00edt\u00e9ssel. Ha van \u00f6tleted a benchmarkok jav\u00edt\u00e1s\u00e1ra - \u00f6r\u00f6mmel v\u00e1rom a pull requestedet. Az \u00f6sszes k\u00f3d \u00e9s a futtat\u00e1si utas\u00edt\u00e1sok az al\u00e1bbiakban tal\u00e1lhat\u00f3ak <noindex><a rel=\"nofollow\" href=\"https:\/\/github.com\/tarantool-php\/benchmarks\">t\u00e1rhelyen<\/a><\/noindex>.<br \/>\n<br \/>Forr\u00e1s: <a content=\"nofollow\" rel=\"nofollow\" href=\"https:\/\/habr.com\/ru\/company\/mailru\/blog\/478336\/\">habr.com<\/a><\/p>","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"excerpt":{"rendered":"<p>\u0412 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 PHP \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u0432\u0430 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c Tarantool \u2015 \u044d\u0442\u043e \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435 PECL tarantool\/tarantool-php, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043d\u0430 \u0421, \u0438 tarantool-php\/client, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 PHP. \u042f \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u0430\u0432\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0435\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c, \u043a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f [&hellip;]<\/p>\n","protected":false,"gt_translate_keys":[{"key":"rendered","format":"html"}]},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[688],"tags":[],"class_list":["post-53530","post","type-post","status-publish","format-standard","hentry","category-administrirovanie"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.3 - aioseo.com -->\n\t<meta name=\"description\" content=\"\u0412 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 PHP.\" \/>\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\/hu\/blog\/administrirovanie\/uskoryaem-php-konnektory-dlya-tarantool-s-pomoshhyu-async-swoole-i-parallel\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.3\" \/>\n\t\t<meta property=\"og:locale\" content=\"hu_HU\" \/>\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\udd47\u0423\u0441\u043a\u043e\u0440\u044f\u0435\u043c PHP-\u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u044b \u0434\u043b\u044f Tarantool \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Async, Swoole \u0438 Parallel | ProHoster\" \/>\n\t\t<meta property=\"og:description\" content=\"\u0412 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 PHP.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/prohoster.info\/hu\/blog\/administrirovanie\/uskoryaem-php-konnektory-dlya-tarantool-s-pomoshhyu-async-swoole-i-parallel\" \/>\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=\"2019-12-03T21:00:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2020-02-18T11:01:26+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\udd47Felgyors\u00edtjuk a PHP-kapcsol\u00f3kat a Tarantoolhoz Async, Swoole \u00e9s Parallel seg\u00edts\u00e9g\u00e9vel | ProHoster","description":"A PHP \u00f6kosziszt\u00e9m\u00e1ban.","canonical_url":"https:\/\/prohoster.info\/hu\/blog\/administrirovanie\/uskoryaem-php-konnektory-dlya-tarantool-s-pomoshhyu-async-swoole-i-parallel","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":null,"og:locale":"hu_HU","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\udd47\u0423\u0441\u043a\u043e\u0440\u044f\u0435\u043c PHP-\u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u044b \u0434\u043b\u044f Tarantool \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Async, Swoole \u0438 Parallel | ProHoster","og:description":"\u0412 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0435 PHP.","og:url":"https:\/\/prohoster.info\/hu\/blog\/administrirovanie\/uskoryaem-php-konnektory-dlya-tarantool-s-pomoshhyu-async-swoole-i-parallel","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":"2019-12-03T21:00:00+00:00","article:modified_time":"2020-02-18T11:01:26+00:00","article:publisher":"https:\/\/www.facebook.com\/prohoster","article:author":"https:\/\/www.facebook.com\/prohoster"},"aioseo_meta_data":{"post_id":"53530","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":"2026-01-24 07:46:24","breadcrumb_settings":null,"limit_modified_date":false,"reviewed_by":null,"ai":null,"created":"2021-02-28 20:23:55","updated":"2026-01-24 07:46:24","focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"gt_translate_keys":[{"key":"link","format":"url"}],"_links":{"self":[{"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/posts\/53530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/comments?post=53530"}],"version-history":[{"count":0,"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/posts\/53530\/revisions"}],"wp:attachment":[{"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/media?parent=53530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/categories?post=53530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prohoster.info\/hu\/wp-json\/wp\/v2\/tags?post=53530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}