{"id":580,"date":"2025-05-19T13:13:19","date_gmt":"2025-05-19T04:13:19","guid":{"rendered":"https:\/\/tako.nakano.net\/blog\/?p=580"},"modified":"2025-05-19T13:13:19","modified_gmt":"2025-05-19T04:13:19","slug":"cloud-run-sqlite-performance-part-1","status":"publish","type":"post","link":"https:\/\/tako.nakano.net\/blog\/2025\/05\/cloud-run-sqlite-performance-part-1\/","title":{"rendered":"Cloud Run SQLite Persistence: GCS Mount vs. Litestream Performance Comparison (Part 1)"},"content":{"rendered":"<h1>Cloud Run \u306e Google Cloud Storage \u30de\u30a6\u30f3\u30c8\u3068 Litestream \u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6bd4\u8f03\uff081\u56de\u76ee\uff09<\/h1>\n<h2>\u7d50\u8ad6<\/h2>\n<p>Cloud Run \u306e Google Cloud Storage \u30de\u30a6\u30f3\u30c8\u3068\u3001Litestream \u306e\u3069\u3061\u3089\u306e\u624b\u6cd5\u3082\u3001130 req\/s \u4ee5\u4e0a\u3092\u53d7\u4ed8\u53ef\u80fd\u3067\u3001SQLite3 \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3082\u6c38\u7d9a\u5316\u3067\u304d\u305f\u3002\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3078\u306e\u66f4\u65b0\u3092\u4f34\u3046\u3088\u3046\u306a\u30ea\u30af\u30a8\u30b9\u30c8\u3067\u3082\u3001\u305f\u3063\u305f1\u53f0\u3067 130 req\/s \u7a0b\u5ea6\u306f\u634c\u304f\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001Google Cloud Storage \u30de\u30a6\u30f3\u30c8\u306e\u5834\u5408\u306f\u3001\u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u4e2d\u306b\u65b0\u30ea\u30d3\u30b8\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u3068\u3001\u30c7\u30fc\u30bf\u640d\u5931\u306e\u6050\u308c\u304c\u3042\u308b\u3002<\/p>\n<p>3\u79d2\u306e\u30c6\u30b9\u30c8\u3067\u306f\u77ed\u3059\u304e\u308b\u305f\u3081\u3001\u518d\u5b9f\u9a13\u304c\u5fc5\u8981\u305d\u3046\u3067\u3042\u308b\u3002\u307e\u305f\u3001\u30ec\u30a4\u30c6\u30f3\u30b7\u3092\u4e0b\u3052\u308b\u305f\u3081\u3001Compute Engine VM \u3092\u4f7f\u3063\u3066\u518d\u5b9f\u884c\u3059\u308b\u4e88\u5b9a\u3067\u3042\u308b\u3002<\/p>\n<p>\u4eca\u56de\u306e\u5b9f\u9a13\u3067\u306f\u3001Litestream \u3092\u7b2c1\u4e16\u4ee3\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u5b9f\u884c\u3057\u305f\u5834\u5408\u306b\u3001900\u4e26\u5217\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3092 293.4 req\/s \u3067\u634c\u304f\u3053\u3068\u304c\u3067\u304d\u305f\u3002<\/p>\n<p>\u4eca\u56de\u5b9f\u9a13\u3057\u305f\u7bc4\u56f2\u3067\u306f\u3001\u624b\u6cd5\u9593\u30fb\u4e16\u4ee3\u9593\u3067\u500d\u4ee5\u4e0a\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u9055\u3046\u3068\u3044\u3046\u3053\u3068\u306b\u306f\u306a\u3089\u306a\u305d\u3046\u3060\u3002<\/p>\n<h2>\u672c\u8a18\u4e8b\u306e\u69cb\u6210<\/h2>\n<ul>\n<li>\u7d50\u8ad6<\/li>\n<li>\u672c\u8a18\u4e8b\u306e\u69cb\u6210<\/li>\n<li>\u53c2\u8003\u6587\u732e<\/li>\n<li>\u306f\u3058\u3081\u306b<\/li>\n<li>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6bd4\u8f03\n<ul>\n<li>\u4ed5\u69d8<\/li>\n<li>Cloud Run \u306e Google Cloud Storage \u30de\u30a6\u30f3\u30c8<\/li>\n<li>Litestream<\/li>\n<\/ul>\n<\/li>\n<li>\u8a2d\u5b9a\u6982\u8981\n<ul>\n<li>Cloud Run \u306e Google Cloud Storage \u30de\u30a6\u30f3\u30c8<\/li>\n<li>Litestream<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>\u53c2\u8003\u6587\u732e<\/h2>\n<ul>\n<li><a href=\"https:\/\/cloud.google.com\/run\/docs\/container-contract?hl=ja\">Cloud Run \u30b3\u30f3\u30c6\u30ca \u30e9\u30f3\u30bf\u30a4\u30e0\u306e\u5951\u7d04<\/a> <a href=\"https:\/\/cloud.google.com\/run\/docs\/container-contract?hl=ja\">https:\/\/cloud.google.com\/run\/docs\/container-contract?hl=ja<\/a><\/li>\n<li><a href=\"https:\/\/litestream.io\/guides\/\">Litestream How-To Guides<\/a> <a href=\"https:\/\/litestream.io\/guides\/\">https:\/\/litestream.io\/guides\/<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/fractaledmind\/litestream-ruby\">litestream-ruby<\/a> <a href=\"https:\/\/github.com\/fractaledmind\/litestream-ruby\">https:\/\/github.com\/fractaledmind\/litestream-ruby<\/a><\/li>\n<li><a href=\"https:\/\/memo.yammer.jp\/posts\/cloud-run-litestream\">Heroku\u304b\u3089Cloud Run + Litestream\u3078\u79fb\u884c\u3057\u305f<\/a> <a href=\"https:\/\/memo.yammer.jp\/posts\/cloud-run-litestream\">https:\/\/memo.yammer.jp\/posts\/cloud-run-litestream<\/a><\/li>\n<li><a href=\"https:\/\/muryoimpl.com\/blog\/2025-01-20\/participated-in-hokuriku-3-ken-lightning-talks\/\">\u5317\u9678\u4e09\u770c.rb Lightning Talks in Kanazawa \u306b\u53c2\u52a0\u3057\u3066\u304d\u305f<\/a> <a href=\"https:\/\/muryoimpl.com\/blog\/2025-01-20\/participated-in-hokuriku-3-ken-lightning-talks\/\">https:\/\/muryoimpl.com\/blog\/2025-01-20\/participated-in-hokuriku-3-ken-lightning-talks\/<\/a>\n<ul>\n<li><a href=\"https:\/\/github.com\/muryoimpl\/kzlt-ruby\/blob\/b1334748b50bd44c07ebd51a2e181a5183c094e4\/bin\/prd-entrypoint#L15-L16\">https:\/\/github.com\/muryoimpl\/kzlt-ruby\/blob\/b1334748b50bd44c07ebd51a2e181a5183c094e4\/bin\/prd-entrypoint#L15-L16<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"https:\/\/zenn.dev\/karno\/articles\/eb580d347d7d86\">Litestream \u3067\u601d\u3063\u305f\u3088\u308a\u304a\u91d1\u304c\u639b\u304b\u3063\u3066\u3044\u308b\u3068\u304d\u3001\u3082\u3057\u304b\u3057\u305f\u3089\u6614\u306e\u30c7\u30fc\u30bf\u304c\u6d88\u3048\u3066\u3044\u306a\u3044\u304b\u3082\u3088<\/a> <a href=\"https:\/\/zenn.dev\/karno\/articles\/eb580d347d7d86\">https:\/\/zenn.dev\/karno\/articles\/eb580d347d7d86<\/a><\/li>\n<li><a href=\"https:\/\/note.com\/yasslab\/n\/n89d6850e296d\">Rails 8\u306fSQLite\u3067\u5927\u5e45\u306b\u5f37\u5316\u3055\u308c\u305f\u300c\u500b\u4eba\u304c\u6271\u3048\u308b\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u300d\uff08\u7ffb\u8a33\uff09<\/a> <a href=\"https:\/\/note.com\/yasslab\/n\/n89d6850e296d\">https:\/\/note.com\/yasslab\/n\/n89d6850e296d<\/a><\/li>\n<\/ul>\n<h2>\u306f\u3058\u3081\u306b<\/h2>\n<p>Rails 8 \u3067\u306f\u3001SQLite \u306e\u30b5\u30dd\u30fc\u30c8\u304c\u624b\u539a\u304f\u306a\u308a\u3001\u300c\u672c\u756a\u74b0\u5883\u3082 SQLite \u3067\u52d5\u304b\u3057\u3066\u826f\u3044\u3088\u300d\u3068\u3044\u3046\u72b6\u614b\u3067\u3042\u308b\u3002<\/p>\n<p>Cloud Run \u306f\u3001Google Cloud \u306e Serverless Computing Platform \u3067\u3042\u308a\u3001\u4f7f\u7528\u3057\u3066\u3044\u306a\u3044\u3068\u304d\u306b\u306f\u30b3\u30f3\u30c6\u30ca\u304c0\u306b\u30b9\u30b1\u30fc\u30eb\u30c0\u30a6\u30f3\u3057\u3001\u30ea\u30af\u30a8\u30b9\u30c8\u304c\u6765\u305f\u3068\u304d\u306b\u30b3\u30f3\u30c6\u30ca\u304c\u8d77\u52d5\u3059\u308b\u4ed5\u7d44\u307f\u304c\u5b9f\u73fe\u3067\u304d\u308b\u3002\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3 \u30b5\u30fc\u30d0\u30fc\u306b\u306f\u300c\u72b6\u614b\u300d\u3092\u6301\u305f\u306a\u3044\u306e\u304c\u7406\u60f3\u3060\u304c\u3001\u4f55\u3089\u304b\u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304c\u5fc5\u8981\u306a\u30b5\u30fc\u30d3\u30b9\u304c\u591a\u3044\u3002\u3069\u306e\u3088\u3046\u306b\u6c38\u7d9a\u5316\u3059\u308b\u304b\u306f\u306a\u304b\u306a\u304b\u9762\u767d\u3044\u554f\u984c\u3067\u3042\u308b\u3002Cloud SQL \u306e\u3088\u3046\u306a RDBMS \u3092\u4f7f\u3046\u306e\u304c\u4e00\u822c\u7684\u3060\u304c\u3001\u3053\u3061\u3089\u306f\u300c\u8d77\u52d5\u300d\u3057\u7d9a\u3051\u3066\u4f7f\u3046\u3053\u3068\u304c\u591a\u304f\u3001DB \u304c\u30bc\u30ed \u30b9\u30b1\u30fc\u30eb\u3057\u306a\u3044\u306e\u3067\u3042\u308b\u3002Firestore \u306e\u3088\u3046\u306a Serverless \u306a\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092\u7528\u3044\u308b\u6226\u7565\u3082\u306a\u304f\u306f\u306a\u3044\u3002<\/p>\n<p>\u4e00\u5b9a\u6ce8\u76ee\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u3001\u30b3\u30f3\u30c6\u30ca\u6570\u3092\u6700\u59271\u306b\u5236\u9650\u3057\u3001SQLite \u3092\u30d0\u30c3\u30af\u30a8\u30f3\u30c9 \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u3057\u3066\u4f7f\u7528\u3057\u3064\u3064\u3001Cloud Storage \u306b\u6c38\u7d9a\u5316\u3059\u308b\u3068\u3044\u3046\u6226\u7565\u3067\u3042\u308b\u3002\u30b3\u30f3\u30c6\u30ca\u304c1\u53f0\u3057\u304b\u306a\u3044\u306e\u3067\u3042\u308c\u3070\u3001\u7af6\u5408\u306e\u554f\u984c\u306f\u767a\u751f\u3057\u306a\u3044\u3002\u30b3\u30f3\u30c6\u30ca\u304c\u8d77\u52d5\u3059\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u3067 SQLite \u306e\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3092 Cloud Storage \u304b\u3089\u8aad\u307f\u53d6\u308a\u3001\u30b3\u30f3\u30c6\u30ca\u304c\u7d42\u4e86\u3059\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u3067 Cloud Storage \u306b\u66f8\u304d\u623b\u3057\u304c\u3067\u304d\u3066\u3044\u308c\u3070\u3001\u554f\u984c\u306a\u304f\u52d5\u4f5c\u3057\u305d\u3046\u3060\u2026\u3068\u3044\u3046\u308f\u3051\u3067\u3042\u308b\u3002<\/p>\n<p>Cloud Run \u306f\u3001Google Cloud Storage \u3092\uff08GCS Fuse \u3067\uff09\u30de\u30a6\u30f3\u30c8\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002\u307e\u305f\u3001Litestream \u3068\u3044\u3046\u3001SQLite \u306e DB \u53ca\u3073 WAL \u3092\uff08streaming replication \u3067\uff09Cloud Storage \u306b\u6c38\u7d9a\u5316\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u3042\u308b\u3002\u672c\u8a18\u4e8b\u3067\u306f\u3001\u3069\u3061\u3089\u306e\u65b9\u304c\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306b\u512a\u308c\u308b\u304b\u3001\u6ce8\u610f\u3059\u308b\u3079\u304d\u70b9\u306f\u4f55\u304b\u3092\u691c\u8a3c\u3059\u308b\u3002<\/p>\n<ol>\n<li>Cloud Run \u306e Google Cloud Storage \u30de\u30a6\u30f3\u30c8<\/li>\n<li>Litestream<\/li>\n<\/ol>\n<h2>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6bd4\u8f03<\/h2>\n<h3>\u4ed5\u69d8<\/h3>\n<p>\u8a08\u6e2c\u3055\u308c\u308b\u5074\u306e Ruby on Rails \u306e\u52d5\u4f5c\u306f\u4ee5\u4e0b\u3067\u3042\u308b\u3002<\/p>\n<ul>\n<li><code>id, count<\/code> \u306e2\u30ab\u30e9\u30e0\u3092\u6301\u3064 <code>counters<\/code> \u30c6\u30fc\u30d6\u30eb\u3092\u4f5c\u6210<\/li>\n<li><code>seeds.rb<\/code> \u3067 <code>id = &#039;count_up&#039;, count = 0<\/code> \u306e\u30ec\u30b3\u30fc\u30c9\u30921\u4ef6\u4f5c\u6210<\/li>\n<li><code>\/count_up<\/code> \u3078\u306e POST \u30ea\u30af\u30a8\u30b9\u30c8\u6bce\u306b\u3001<code>id = &#039;count_up&#039;<\/code> \u306e\u30ec\u30b3\u30fc\u30c9\u306e <code>count<\/code> \u30921\u5897\u3084\u3059(<code>update_all(&quot;count = count + 1&quot;)<\/code>)<\/li>\n<li>\u30ec\u30b9\u30dd\u30f3\u30b9\u306b\u306f\u3001<code>count<\/code> \u306e\u5024\u3092 <code>{&quot;count&quot;:4856}<\/code> \u306e\u5f62\u5f0f\u3067\u8fd4\u3059<\/li>\n<li><code>\/count_up<\/code> \u3078\u306e POST \u30ea\u30af\u30a8\u30b9\u30c8\u3092\u591a\u6570\u56de\u5b9f\u884c\u3057\u3001Request per second (RPS) \u3092\u8a08\u6e2c<\/li>\n<\/ul>\n<p>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u8a08\u6e2c\u306b\u306f k6 \u3092\u7528\u3044\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u5358\u7d14\u306a\u30b7\u30ca\u30ea\u30aa\u3092\u5b9f\u884c\u3055\u305b\u305f\u3002<\/p>\n<pre><code class=\"language-javascript\">import http from &#039;k6\/http&#039;;\nimport { check } from &#039;k6&#039;;\n\nexport const options = {\n  vus: 900,\n  duration: &#039;3s&#039;,\n};\n\nexport default function() {\n  const res = http.post(&#039;https:\/\/ URL .asia-northeast1.run.app\/count_up&#039;);\n  check(res, { &quot;status is 200&quot;: (res) =&gt; res.status === 200 });\n}<\/code><\/pre>\n<p>\u30b3\u30f3\u30c6\u30ca\u306e\u540c\u6642\u30ea\u30af\u30a8\u30b9\u30c8\u53d7\u3051\u4ed8\u3051\u6570\u306f 900 \u3068\u3057\u305f\u3002<\/p>\n<p>Cloud Run \u306e\u30b3\u30f3\u30c6\u30ca\u306b\u306f\u30011 vCPU \u3068 512 MB \u306e\u30e1\u30e2\u30ea\u3092\u5272\u308a\u5f53\u3066\u305f\u3002<\/p>\n<h3>Cloud Run \u306e Google Cloud Storage \u30de\u30a6\u30f3\u30c8<\/h3>\n<p>Google Cloud Storage \u30de\u30a6\u30f3\u30c8\u3092\u884c\u3046\u5834\u5408\u3001\u7b2c2\u4e16\u4ee3\u304c\u5fc5\u9808\u3068\u306a\u308b\u3002<\/p>\n<ol>\n<li>150\u4e26\u5217<\/li>\n<\/ol>\n<p><code>vus: 150<\/code> \u3068\u3057\u3001\u8a08\u6e2c\u3057\u305f\u7d50\u679c\u4ee5\u4e0b\u306e\u7d50\u679c\u3092\u5f97\u305f\uff08\u629c\u7c8b\uff09\u3002<\/p>\n<pre><code>    checks_total.......................: 649     179.608057\/s\n    checks_succeeded...................: 100.00% 649 out of 649\n    checks_failed......................: 0.00%   0 out of 649\n\n    HTTP\n    http_req_duration.......................................................: avg=656.82ms min=19.87ms med=730.44ms max=1.71s p(90)=1.48s p(95)=1.53s\n      { expected_response:true }............................................: avg=656.82ms min=19.87ms med=730.44ms max=1.71s p(90)=1.48s p(95)=1.53s\n    http_req_failed.........................................................: 0.00%  0 out of 649\n    http_reqs...............................................................: 649    179.608057\/s\n\nrunning (03.6s), 000\/150 VUs, 649 complete and 0 interrupted iterations<\/code><\/pre>\n<p>179.6 req\/s \u53d7\u4ed8\u3067\u304d\u305f\u3068\u8a00\u3063\u3066\u826f\u3044\u3060\u308d\u3046\u3002<\/p>\n<ol start=\"2\">\n<li>900\u4e26\u5217<\/li>\n<\/ol>\n<p><code>vus: 900<\/code> \u3068\u3057\u3001\u8a08\u6e2c\u3057\u305f\u7d50\u679c\u4ee5\u4e0b\u306e\u7d50\u679c\u3092\u5f97\u305f\uff08\u629c\u7c8b\uff09\u3002<\/p>\n<pre><code>    checks_total.......................: 1441    132.552259\/s\n    checks_succeeded...................: 100.00% 1441 out of 1441\n    checks_failed......................: 0.00%   0 out of 1441\n\n    HTTP\n    http_req_duration.......................................................: avg=4.14s min=21.17ms med=3.24s max=9.39s p(90)=8.85s p(95)=9.14s\n      { expected_response:true }............................................: avg=4.14s min=21.17ms med=3.24s max=9.39s p(90)=8.85s p(95)=9.14s\n    http_req_failed.........................................................: 0.00%  0 out of 1441\n    http_reqs...............................................................: 1441   132.552259\/s\n\n    EXECUTION\n    vus.....................................................................: 110    min=110       max=900\n    vus_max.................................................................: 900    min=900       max=900\n\nrunning (10.9s), 000\/900 VUs, 1441 complete and 0 interrupted iterations\ndefault \u2713 [======================================] 900 VUs  3s<\/code><\/pre>\n<p>\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u306f\u4f38\u3073\u306a\u304b\u3063\u305f\u2026\u3068\u3044\u3046\u304b\u60aa\u5316\u3057\u305f\u3002<br \/>\n132.6 req\/s \u53d7\u4ed8\u3067\u304d\u305f\u3068\u8a00\u3063\u3066\u826f\u3044\u3060\u308d\u3046\u3002<\/p>\n<h3>Litestream<\/h3>\n<p>Litestream \u306e\u52d5\u4f5c\u306b\u306f\u7279\u5225\u306a\u8981\u4ef6\u304c\u306a\u3044\u305f\u3081\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u4e16\u4ee3\uff082025-05 \u6642\u70b9\u3067\u306f\u7b2c1\u4e16\u4ee3\uff09\u3068\u3001\u7b2c2\u4e16\u4ee3\u3092\u6307\u5b9a\u3057\u305f\u3082\u306e\u3001\u4e21\u65b9\u306b\u3064\u3044\u3066\u78ba\u8a8d\u3057\u305f\u3002<\/p>\n<p>\u7b2c1\u4e16\u4ee3<\/p>\n<ol>\n<li>150\u4e26\u5217<\/li>\n<\/ol>\n<p><code>vus: 150<\/code> \u3068\u3057\u3001\u8a08\u6e2c\u3057\u305f\u7d50\u679c\u4ee5\u4e0b\u306e\u7d50\u679c\u3092\u5f97\u305f\uff08\u629c\u7c8b\uff09\u3002<\/p>\n<pre><code>    checks_total.......................: 633     135.508697\/s\n    checks_succeeded...................: 100.00% 633 out of 633\n    checks_failed......................: 0.00%   0 out of 633\n\n    HTTP\n    http_req_duration.......................................................: avg=957.61ms min=21.95ms med=647.31ms max=3.34s p(90)=2.89s p(95)=3.1s \n      { expected_response:true }............................................: avg=957.61ms min=21.95ms med=647.31ms max=3.34s p(90)=2.89s p(95)=3.1s \n    http_req_failed.........................................................: 0.00%  0 out of 633\n    http_reqs...............................................................: 633    135.508697\/s\n\nrunning (04.7s), 000\/150 VUs, 633 complete and 0 interrupted iterations\ndefault \u2713 [======================================] 150 VUs  3s\n<\/code><\/pre>\n<p>135.5 req\/s \u53d7\u4ed8\u3067\u304d\u305f\u3068\u8a00\u3063\u3066\u826f\u3044\u3060\u308d\u3046\u3002<\/p>\n<ol start=\"2\">\n<li>900\u4e26\u5217<\/li>\n<\/ol>\n<p><code>vus: 900<\/code> \u3068\u3057\u3001\u8a08\u6e2c\u3057\u305f\u7d50\u679c\u4ee5\u4e0b\u306e\u7d50\u679c\u3092\u5f97\u305f\uff08\u629c\u7c8b\uff09\u3002<\/p>\n<pre><code>    checks_total.......................: 1637    293.350468\/s\n    checks_succeeded...................: 100.00% 1637 out of 1637\n    checks_failed......................: 0.00%   0 out of 1637\n\n    HTTP\n    http_req_duration.......................................................: avg=1.62s min=21.43ms med=2.18s max=3.22s p(90)=2.97s p(95)=3.06s\n      { expected_response:true }............................................: avg=1.62s min=21.43ms med=2.18s max=3.22s p(90)=2.97s p(95)=3.06s\n    http_req_failed.........................................................: 0.00%  0 out of 1637\n    http_reqs...............................................................: 1637   293.350468\/s\n\n    EXECUTION\n    vus.....................................................................: 213    min=213       max=900\n    vus_max.................................................................: 900    min=900       max=900\n\nrunning (05.6s), 000\/900 VUs, 1637 complete and 0 interrupted iterations\ndefault \u2713 [======================================] 900 VUs  3s<\/code><\/pre>\n<p>293.4 req\/s \u3060\u3063\u305f\u3002\u500d\u4ee5\u4e0a\u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u51fa\u3066\u3044\u308b\u3088\u3046\u3060\u3002<\/p>\n<p>\u7b2c2\u4e16\u4ee3<\/p>\n<ol>\n<li>150\u4e26\u5217<\/li>\n<\/ol>\n<p><code>vus: 150<\/code> \u3068\u3057\u3001\u8a08\u6e2c\u3057\u305f\u7d50\u679c\u4ee5\u4e0b\u306e\u7d50\u679c\u3092\u5f97\u305f\uff08\u629c\u7c8b\uff09\u3002<\/p>\n<pre><code>    checks_total.......................: 557     148.273847\/s\n    checks_succeeded...................: 100.00% 557 out of 557\n    checks_failed......................: 0.00%   0 out of 557\n\n    HTTP\n    http_req_duration.......................................................: avg=855.4ms  min=21.62ms med=955.69ms max=2.02s p(90)=1.61s p(95)=1.83s\n      { expected_response:true }............................................: avg=855.4ms  min=21.62ms med=955.69ms max=2.02s p(90)=1.61s p(95)=1.83s\n    http_req_failed.........................................................: 0.00%  0 out of 557\n    http_reqs...............................................................: 557    148.273847\/s\n\nrunning (03.8s), 000\/150 VUs, 557 complete and 0 interrupted iterations\ndefault \u2713 [======================================] 150 VUs  3s<\/code><\/pre>\n<p>148.3 req\/s \u53d7\u4ed8\u3067\u304d\u305f\u3068\u8a00\u3063\u3066\u826f\u3044\u3060\u308d\u3046\u3002\u82e5\u5e72\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u304c\u4e0a\u304c\u3063\u3066\u3044\u308b\u3088\u3046\u3060\u304c\u3001\u8a08\u6e2c\u8aa4\u5dee\u7a0b\u5ea6\u3068\u8a00\u3048\u306a\u304f\u3082\u306a\u3044\u3002<\/p>\n<ol start=\"2\">\n<li>900\u4e26\u5217<\/li>\n<\/ol>\n<p><code>vus: 900<\/code> \u3068\u3057\u3001\u8a08\u6e2c\u3057\u305f\u7d50\u679c\u4ee5\u4e0b\u306e\u7d50\u679c\u3092\u5f97\u305f\uff08\u629c\u7c8b\uff09\u3002<\/p>\n<pre><code>    checks_total.......................: 1347    178.225271\/s\n    checks_succeeded...................: 100.00% 1347 out of 1347\n    checks_failed......................: 0.00%   0 out of 1347\n\n    HTTP\n    http_req_duration.......................................................: avg=2.97s min=22.08ms med=3.46s max=5.87s p(90)=5.34s p(95)=5.52s\n      { expected_response:true }............................................: avg=2.97s min=22.08ms med=3.46s max=5.87s p(90)=5.34s p(95)=5.52s\n    http_req_failed.........................................................: 0.00%  0 out of 1347\n    http_reqs...............................................................: 1347   178.225271\/s\n\n    EXECUTION\n    vus.....................................................................: 123    min=123       max=900\n    vus_max.................................................................: 900    min=900       max=900\n\nrunning (07.6s), 000\/900 VUs, 1347 complete and 0 interrupted iterations\ndefault \u2713 [======================================] 900 VUs  3s<\/code><\/pre>\n<p>178.2 req\/s \u53d7\u4ed8\u3067\u304d\u305f\u3068\u8a00\u3063\u3066\u826f\u3044\u3060\u308d\u3046\u3002150\u4e26\u5217\u3088\u308a\u306f\u826f\u3044\u3088\u3046\u3060\u3002<\/p>\n<p>\u7b2c1\u4e16\u4ee3\u3088\u308a\u5024\u304c\u60aa\u304b\u3063\u305f\u306e\u3067\u3001\u518d\u5ea6\u5b9f\u884c\u3057\u3066\u307f\u305f\u3002<\/p>\n<pre><code>    checks_total.......................: 1361    185.216461\/s\n    checks_succeeded...................: 100.00% 1361 out of 1361\n    checks_failed......................: 0.00%   0 out of 1361\n\n    HTTP\n    http_req_duration.......................................................: avg=2.78s min=21.93ms med=3.21s max=5.69s p(90)=5.32s p(95)=5.45s\n      { expected_response:true }............................................: avg=2.78s min=21.93ms med=3.21s max=5.69s p(90)=5.32s p(95)=5.45s\n    http_req_failed.........................................................: 0.00%  0 out of 1361\n    http_reqs...............................................................: 1361   185.216461\/s\n\n    EXECUTION\n    vus.....................................................................: 79     min=79        max=900\n    vus_max.................................................................: 900    min=900       max=900\n\nrunning (07.3s), 000\/900 VUs, 1361 complete and 0 interrupted iterations\ndefault \u2713 [======================================] 900 VUs  3s<\/code><\/pre>\n<p>185.2 req\/s \u3067\u3042\u308a\u3001\u3072\u3068\u3064\u524d\u306e\u30c6\u30b9\u30c8\u3068\u306f\u3042\u307e\u308a\u5909\u5316\u304c\u306a\u304b\u3063\u305f\u3002<\/p>\n<h2>\u8a2d\u5b9a\u6982\u8981<\/h2>\n<h3>Cloud Run \u306e Google Cloud Storage \u30de\u30a6\u30f3\u30c8<\/h3>\n<p>Google Cloud Storage \u30de\u30a6\u30f3\u30c8\u306f\u3001Cloud Run \u306e\u5b9f\u884c\u74b0\u5883\u306e\u3046\u3061\u3001The second generation \u306e\u307f\u3067\u5229\u7528\u3067\u304d\u308b <a href=\"https:\/\/cloud.google.com\/run\/docs\/container-contract?hl=ja\">Cloud Run \u30b3\u30f3\u30c6\u30ca \u30e9\u30f3\u30bf\u30a4\u30e0\u306e\u5951\u7d04<\/a>\u3002<\/p>\n<p>\u5148\u306b\u6ce8\u610f\u4e8b\u9805\u3092\u66f8\u3044\u3066\u304a\u304f\u3068\u3001\u300c\u672a\u4fdd\u5b58\u306e\u30c7\u30fc\u30bf\u304c\u3042\u308b\u72b6\u614b\u3067\u3001\u65b0\u30ea\u30d3\u30b8\u30e7\u30f3\u306e\u4f5c\u6210\u7b49\u3067\u65b0\u3057\u3044\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u30ed\u30fc\u30c9\u3057\u3066\u30011\u6642\u7684\u306b2\u53f0\u4ee5\u4e0a\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u5b58\u5728\u3057\u3066\u3057\u307e\u3046\u3068\u3001\u30c7\u30fc\u30bf\u306e\u4e00\u90e8\uff08\u6700\u65b0\u306e WAL \u5206\uff09\u304c\u5931\u308f\u308c\u308b\u300d\u3068\u3044\u3046\u3053\u3068\u3067\u3042\u308b\u3002\u30c7\u30fc\u30bf\u3092\u5931\u308f\u306a\u3044\u305f\u3081\u306b\u3001\u30a2\u30af\u30bb\u30b9\u304c\u5168\u304f\u6765\u3066\u304a\u3089\u305a\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c0\u306e\u72b6\u614b\u3067\u3001Cloud Run \u306e\u65b0\u3057\u3044\u30ea\u30d3\u30b8\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u306e\u304c\u826f\u3044\u3002\u524d\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b <code>\/count_up<\/code> \u3092\u884c\u3063\u3066\u3044\u308b\u6bb5\u968e\u3067\u3001Cloud Storage \u306b WAL \u304c\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u306e\u3082\u78ba\u8a8d\u3067\u304d\u305f\u304c\u3001\u65b0\u3057\u3044\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u305d\u308c\u3092\u30ed\u30fc\u30c9\u3057\u306a\u3044\u306e\u304b\u3001\u826f\u304f\u5206\u304b\u3089\u306a\u304b\u3063\u305f\u3002\u4e00\u5b9a\u91cf\u306e\u4fdd\u5b58\u3092\u884c\u3063\u305f\u3068\u304d\u3068\u3001\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e\u7d42\u4e86\u6642\u306b\u306f\u3001WAL \u304b\u3089 DB \u306b\u66f8\u304d\u623b\u3059\u51e6\u7406\u304c\u884c\u308f\u308c\u308b\u304c\u3001\u305d\u3046\u3057\u3066 <code>.sqlite3<\/code> \u30d5\u30a1\u30a4\u30eb\u306b\u306a\u3063\u3066\u3044\u305f\u72b6\u614b\u3067\u3042\u308c\u3070\u3001\u30c7\u30fc\u30bf\u304c\u5931\u308f\u308c\u308b\u3053\u3068\u306f\u306a\u3044\u3088\u3046\u3060\u3063\u305f\u3002<\/p>\n<p>\u7d30\u304b\u3044\u3068\u3053\u308d\u306f\u3001GitHub \u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u3044\u308b\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9 <a href=\"https:\/\/github.com\/takotakot\/rails8-google-cloud-example\/tree\/main\/db-cloud-storage\">db-cloud-storage https:\/\/github.com\/takotakot\/rails8-google-cloud-example\/tree\/main\/db-cloud-storage<\/a> \u3092\u53c2\u7167\u3057\u3066\u307b\u3057\u3044\u3002\u8981\u70b9\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3001\u30d0\u30b1\u30c3\u30c8\u540d (id) \u3068\u30de\u30a6\u30f3\u30c8\u5148\u306e\u30d1\u30b9 (mount_path) \u3092\u6307\u5b9a\u3059\u308b\u3060\u3051\u3067\u3042\u308b\u3002<\/p>\n<pre><code class=\"language-terraform\"># ...\n    {\n      volume_mounts {\n        name = &quot;sqlite-bucket&quot;\n        # See Dockerfile WORKDIR\n        mount_path = &quot;\/rails\/storage&quot;\n      }\n\n    }\n\n# ...\n    volumes {\n      name = &quot;sqlite-bucket&quot;\n      gcs {\n        bucket    = google_storage_bucket.sqlite_bucket.name\n        read_only = false\n      }\n    }<\/code><\/pre>\n<p>\u7d30\u304b\u3044\u30b3\u30df\u30c3\u30c8\u5c65\u6b74\u304c\u8ffd\u3044\u305f\u3051\u308c\u3070\u3001<a href=\"https:\/\/github.com\/takotakot\/rails8-google-cloud-example\/pull\/5\">Pull Request #5<\/a> \u306e2\u30b3\u30df\u30c3\u30c8\u76ee\u4ee5\u964d\u304c\u826f\u3044\u3060\u308d\u3046\u3002<\/p>\n<h3>Litestream<\/h3>\n<p>Litestream \u306f\u3001SQLite \u306e WAL \u3092 Cloud Storage \u306b\u6c38\u7d9a\u5316\u3059\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3042\u308b\u3002\u4e16\u4ee3 (generation) \u306e\u7ba1\u7406\u6a5f\u80fd\u3068\u3001\u5fa9\u5143 (restore) \u6a5f\u80fd\u3082\u6301\u3064\u3002WAL \u3092\u898b\u5f35\u308a\u3001\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u8ee2\u9001\u3057\u3066\u304f\u308c\u308b\u3002<a href=\"https:\/\/github.com\/fractaledmind\/litestream-ruby\">litestream-ruby<\/a> \u306f\u3001Ruby \u3067 Litestream \u3092\u7c21\u5358\u306b\u4f7f\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u305f\u3081\u306e Gem \u3067\u3042\u308b\u3002Gem \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3001<code>litestream.yml<\/code> \u3092\u4f5c\u6210\u3059\u308b\u3060\u3051\u3067\u3001SQLite \u306e DB \u3068 WAL \u3092 Cloud Storage \u306b\u6c38\u7d9a\u5316\u3067\u304d\u308b\u3002<\/p>\n<p>Litestream \u3092\u4f7f\u7528\u3059\u308b\u3068\u3001\u30b3\u30f3\u30c6\u30ca\u8d77\u52d5\u6642\u306b\u3001\u6700\u65b0\u306e\u30c7\u30fc\u30bf\u3092 Cloud Storage \u304b\u3089\u30b3\u30d4\u30fc\u3057\u3001\u66f4\u65b0\u304c\u66f8\u304d\u8fbc\u307e\u308c\u308b\u5ea6\u306b\u3001\u5dee\u5206\u3092 Cloud Storage \u306b\u30b9\u30c8\u30ea\u30fc\u30df\u30f3\u30b0\u3067\u66f8\u304d\u51fa\u3059\u2026\u3068\u3044\u3046\u3053\u3068\u304c\u5b9f\u73fe\u3067\u304d\u308b\u3002<\/p>\n<p>\u30b9\u30c8\u30ea\u30fc\u30df\u30f3\u30b0\u4fdd\u5b58\u3067\u3042\u308b\u305f\u3081\u3001Cloud Storage \u30d0\u30b1\u30c3\u30c8\u3092\u76f4\u63a5\u30de\u30a6\u30f3\u30c8\u3059\u308b\u65b9\u6cd5\u3068\u7570\u306a\u308a\u3001\u65b0\u30ea\u30d3\u30b8\u30e7\u30f3\u306e\u4f5c\u6210\u7b49\u3067\u65b0\u3057\u3044\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u30ed\u30fc\u30c9\u3057\u3066\u30011\u6642\u7684\u306b2\u53f0\u4ee5\u4e0a\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304c\u5b58\u5728\u3057\u3066\u3057\u307e\u3063\u3066\u3082\u3001\u30c7\u30fc\u30bf\u640d\u5931\u306f\u767a\u751f\u3057\u306a\u304b\u3063\u305f\u3002<\/p>\n<p>\u5168\u4f53\u306b\u3064\u3044\u3066\u306f\u5225\u8a18\u4e8b\u306b\u8b72\u308b\u3068\u3057\u3066\u3001\u4e3b\u8981\u306a\u8a2d\u5b9a\u306f\u4ee5\u4e0b\u3067\u3042\u308b\u3002Cloud Run \u3067\u5b9f\u884c\u3059\u308b\u5834\u5408\u3001\u81ea\u52d5\u7684\u306b\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u8aad\u307f\u53d6\u3063\u3066\u8a8d\u8a3c\u3055\u308c\u305f\u72b6\u614b\u3067\u5b9f\u884c\u3057\u3066\u304f\u308c\u308b\u3088\u3046\u3060\u3063\u305f\u3002<\/p>\n<pre><code class=\"language-sh:docker-entrypoint\">  if [ &quot;${LITESTREAM_REPLICA_BUCKET}&quot; ]; then\n    # Restore databases\n    for db in &quot;.sqlite3&quot; &quot;_cable.sqlite3&quot; &quot;_cache.sqlite3&quot; &quot;_queue.sqlite3&quot;; do\n      .\/bin\/rails litestream:restore -- --database=&quot;storage\/${RAILS_ENV}${db}&quot; --if-replica-exists\n    done<\/code><\/pre>\n<pre><code class=\"language-yaml:litestream.yml\">dbs:\n  - path: storage\/production.sqlite3\n    replicas:\n      - type: gcs\n        bucket: $LITESTREAM_REPLICA_BUCKET\n        path: production.sqlite3\n  - path: storage\/production_cache.sqlite3\n    replicas:\n      - type: gcs\n        bucket: $LITESTREAM_REPLICA_BUCKET\n        path: production_cache.sqlite3\n  - path: storage\/production_queue.sqlite3\n    replicas:\n      - type: gcs\n        bucket: $LITESTREAM_REPLICA_BUCKET\n        path: production_queue.sqlite3\n  - path: storage\/production_cable.sqlite3\n    replicas:\n      - type: gcs\n        bucket: $LITESTREAM_REPLICA_BUCKET\n        path: production_cable.sqlite3<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Cloud Run \u306e Google Cloud Storage \u30de\u30a6\u30f3\u30c8\u3068 Litestream \u306e\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u6bd4\u8f03\uff081\u56de\u76ee\uff09 \u7d50\u8ad6 Cloud Run \u306e Google Cloud Storage \u30de\u30a6\u30f3\u30c8\u3068\u3001Li [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[26,13,14],"tags":[],"class_list":["post-580","post","type-post","status-publish","format-standard","hentry","category-cloud-run","category-google-cloud","category-ruby"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4dIdP-9m","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/posts\/580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/comments?post=580"}],"version-history":[{"count":1,"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/posts\/580\/revisions"}],"predecessor-version":[{"id":581,"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/posts\/580\/revisions\/581"}],"wp:attachment":[{"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/media?parent=580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/categories?post=580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tako.nakano.net\/blog\/wp-json\/wp\/v2\/tags?post=580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}