Dyno減らせた分、Stream APIに回してみようかな
Mastodonのstreaming APIを有効にする手順を追加しました
@ms2sato プラットフォームがメンテナンスをした時にサーバを移動させる必要があったときに、DATABASE_URLとかREDIS_URLを変更しちゃうので、手作業でコピーしちゃうと接続できなくなっちゃうんですよね~。addons:attachしておけばプラットフォーム側で追随させてくれるので、あとはDynoの起動時にDyno内でバラすことになります。
Current database status:
$ heroku pg:info DATABASE
=== DATABASE_URL, PG_HOBBY_BASIC_URL
Plan: Hobby-basic
Status: Available
Connections: 7/20
PG Version: 9.6.1
Created: 2017-04-20 18:31 UTC
Data Size: 22.0 MB
Tables: 26
Rows: 17226/10000000 (In compliance)
Growth of Hobby-tier Heroku Postgres for this instance. https://mastodon.zunda.ninja/media/3ICDvJS5ZUvVfty1ogg
このインスタンスの台所事情をまとめました。現在$16/月ですが、アプリケーションログの容量があふれていることに対処する必要がありそうです
https://github.com/zunda/mastodon/wiki/CostConsiderationsOnHeroku
Current status on database:
$ heroku pg:info DATABASE=== DATABASE_URL, PG_HOBBY_BASIC_URL
Plan: Hobby-basic
Status: Available
Connections: 9/20
PG Version: 9.6.1
Created: 2017-04-20 18:31 UTC
Data Size: 24.8 MB
Tables: 26
Rows: 20949/10000000 (In compliance)
およ。Raspberry Piのメモリ1GBあるん?なんとかなりそう…ここで512MBにはPostgreSQLを入れてないことに思い至る
@hyuki Dyno 2台とHeroku Postgres Hobby-basicだと1カレンダー月あたり$7×2+$9なので5日間で$3.80くらいになりそうですねー
Current database status:
$ heroku pg:info DATABASE
=== DATABASE_URL, PG_HOBBY_BASIC_URL
Plan: Hobby-basic
Status: Available
Connections: 7/20
PG Version: 9.6.1
Created: 2017-04-20 18:31 UTC
Data Size: 26.2 MB
Tables: 26
Rows: 22495/10000000 (In compliance)
Deployed 33c46f7 from https://github.com/zunda/mastodon/tree/zunda-ninja-on-heroku . The [Procfile](https://github.com/zunda/mastodon/blob/33c46f7aec4a752270f6ad52758501cf17886951/Procfile) allows me to deploy same slug to the main app as well as the app responsible for streaming API with the following config vars:
Main app:
heroku config:set RUN_WEB=true
heroku config:set RUN_WORKER=true
App for streaming API:
heroku config:set RUN_STREAMING=true
リモートブランチを削除するよろこび
$ git push --delete origin zunda-ninja-streaming-on-heroku
江副さんが出社するとぼっちインスタンスのタイムラインが止まるのでStreaming APIが動いてるのか気になる
Database status on this instance:
$ heroku pg:info DATABASE
=== DATABASE_URL, PG_HOBBY_BASIC_URL
Plan: Hobby-basic
Status: Available
Connections: 7/20
PG Version: 9.6.1
Created: 2017-04-20 18:31 UTC
Data Size: 27.1 MB
Tables: 26
Rows: 23971/10000000 (In compliance)
source=REDIS_URL sample#num_connections_over_limit=0 message=Database connections over limit. Please upgrade your database plan.
Oops
Finally, I'm going ahead to remove the account and factory reset my Nexus 5 I broke the other day. It was a good device (-人-)
Data on this instance:
$ heroku pg:info DATABASE
=== DATABASE_URL, PG_HOBBY_BASIC_URL
Plan: Hobby-basic
Status: Available
Connections: 7/20
PG Version: 9.6.1
Created: 2017-04-20 18:31 UTC
Data Size: 28.6 MB
Tables: 26
Rows: 26723/10000000 (In compliance)
Puma and sidekiq are using slightly more memory than it should be using. Let's see what happens when moving from cedar-14 to heroku-16.
$ heroku stack:set heroku-16
Stack set. Next release will use heroku-16.
Run git push heroku master to create a new release https://mastodon.zunda.ninja/media/p8VR4hUvvRlfHHnz7VM
Well, promotion on the pipeline did not update the stacks.
$ git push heroku zunda-ninja-on-heroku:master
$ heroku stack
=== Available Stacks
* heroku-16
cedar-14
Yup. Did the same thing for the app for streaming API :)
$ sudo sync;sudo sync;sudo sync;sudo reboot
(-人-)
Somewhere I learnt that `sync` does not need `sudo` to sync everything on the machine but I forgot where and I'm not sure if this is correct.
It seems that Mastodon (puma+sidekiq) consumes less memory on Herku-16 (Ubuntu 16.04; switched at v47 in the plots) than on Cedar-14 (Ubuntu 14.04). https://mastodon.zunda.ninja/media/CRXvtvRGPJBAp_S5EA0
自分がログインしているインタンスのアカウントをリモートフォローするのに手間がかかる。
https://インスタンス/users/アカウント/remote_follow を閲覧して手続きを進める。
@ykzts おおお! と思ったのですが、自インスタンスが対象のアカウントを知らない時には検索結果にあらわれないんですよね。
@ykzts 出てきました! 少しラグがあるようですね。リモートに問い合わせに行ってるんだろうな。
Still doing better in memory consumption on Heroku-16 (v47 and after) than Cedar-14 https://mastodon.zunda.ninja/media/bGxR8cQCvz_eK0ogqFw
Data on this instance:
$ heroku pg:info DATABASE
=== DATABASE_URL, PG_HOBBY_BASIC_URL
Plan: Hobby-basic
Status: Available
Connections: 7/20
PG Version: 9.6.1
Created: 2017-04-20 18:31 UTC
Data Size: 29.0 MB
Tables: 26
Rows: 26900/10000000 (In compliance)
Well, actually, Heroku-16 is no better than Cedar-14 once ImageMagick kicks in to consume memory.
@kojira たぶん zundan@mastodon.zunda.ninja に送っていただけると把握できる可能性が一番たかいです。他はログインしてなかったりブラウザ開いてなかったりすることが多いです。
@kojira ですねー。インスタンスからweb socketつないどく必要がありそうなので、クライアント側に実装する感じになりそうですね…とか思うとマルチインスタンスに使えるクライアントアプリにたどりついちゃいそう。
Comparison of memory use between Heroku's Cedar-14 stack (Ubunt 14.04; left) and Heroku-16 stack (Ubuntu 16.04; right) on this instance with single account running Puma (2 workers with 3 threads) and Sidekiq. Decreases in swap use after a peak seem to be different between stacks. https://mastodon.zunda.ninja/media/9brhqRf0Sz8HbU75F6M
Current status:
heroku pg:info DATABASE
=== DATABASE_URL, PG_HOBBY_BASIC_URL
Plan: Hobby-basic
Status: Available
Connections: 8/20
PG Version: 9.6.1
Created: 2017-04-20 18:31 UTC
Data Size: 29.7 MB
Tables: 26
Rows: 28009/10000000 (In compliance)
All the R14s on Heroku-16 stack. I should decrease number of threads from 3 to 2.
$ heroku config:set MAX_THREADS=2 https://mastodon.zunda.ninja/media/9rfhoc55PzmmJtniAnI
Ah, OK, I should retain DB_POOL at, say, 5:
ActiveRecord::ConnectionTimeoutError: could not obtain a connection from the pool within 5.000 seconds
$ git grep DB_POOL
config/database.yml: pool: <%= ENV["DB_POOL"] || ENV['MAX_THREADS'] || 5 %>
$ heroku config:set DB_POOL=5
$ git pull upstream
$ git rebase upstream/master
$ git rev-parse master
ebbbcfef1c805efbf0c6b80e4e9f1d7bcddba2ba
$ git checkout zunda-ninja-on-heroku
$ git merge master
$ git push
$ git checkout master
$ git push
and this instance is on 833ae4f in zunda-ninja-on-heroku branch.
It seems that replying to a CW toot posted the original toot without the reply.
Deployed the branch with a39e719b392f2a2de3415850ff04deeefd3e8742 from upstream/master merged.
Current status:
$ heroku pg:info DATABASE
=== DATABASE_URL, PG_HOBBY_BASIC_URL
Plan: Hobby-basic
Status: Available
Connections: 8/20
PG Version: 9.6.1
Created: 2017-04-20 18:31 UTC
Data Size: 31.2 MB
Tables: 26
Rows: 30457/10000000 (In compliance)
It seems that the latest deploy (v51 that has a39e71, i.e., v1.3.1+, from upstream/master) shows elevated tail in response time.
a39e71 (v51) on Heroku-16 might have worse memory profile or might this just be from invocatinos of ImageMagick?
The spike in throughput as well as response time seems to correspond to a spike in requests to `/users/zundan.atom` from various IP addresses. Might there be a bot network or something? https://mastodon.zunda.ninja/media/Y0r0h__al0tPdKlXNEw
Database status:
$ heroku pg:info DATABASE
=== DATABASE_URL, PG_HOBBY_BASIC_URL
Plan: Hobby-basic
Status: Available
Connections: 13/20
PG Version: 9.6.1
Created: 2017-04-20 18:31 UTC
Data Size: 31.8 MB
Tables: 26
Rows: 31751/10000000 (In compliance)
Merged a823509 from upstream to the code this instance is running on. Let's see how it runs :)
$ heroku pg:info DATABASE
=== DATABASE_URL, PG_HOBBY_BASIC_URL
Plan: Hobby-basic
Status: Available
Connections: 8/20
PG Version: 9.6.1
Created: 2017-04-20 18:31 UTC
Data Size: 32.3 MB
Tables: 26
Rows: 31927/10000000 (In compliance)
むっちゃ書きかけですが、Heroku Postgresからのデータの取り出し方を書きました
@Gargron https://mastodon.zunda.ninja/ has been running just fine :+1:
$ git fetch upstream
$ git checkout zunda-ninja-on-heroku
$ git pull
$ git merge v1.3.2
$ git push
$ git checkout master
$ git pull
$ git rebase upstream/master
$ git push
Updated this instance to v1.3.2.
Downtime was from 2017-04-29T21:46:36.936465+00:00 to 2017-04-29T21:47:03.708810+00:00.
Database status.
$ heroku pg:info DATABASE
=== DATABASE_URL, PG_HOBBY_BASIC_URL
Plan: Hobby-basic
Status: Available
Connections: 8/20
PG Version: 9.6.1
Created: 2017-04-20 18:31 UTC
Data Size: 33.3 MB
Tables: 26
Rows: 34040/10000000 (In compliance)