perf(stats): read peers from instances, update every 5 minutes
The peers query read the nickname of every remote user every minute (2.7 s and 1.2M buffer hits on a large instance). The instances table now has a row for every host we know users from, so read it instead, and recompute the stats every 5 minutes. Based on Akkoma 138b1aea2 and 7b76fdeed. Co-authored-by: Oneric <oneric@oneric.stub> Co-authored-by: FloatingGhost <hannah@coffee-and-dreams.uk>
This commit is contained in:
parent
db11e5e790
commit
e8f238359f
3 changed files with 11 additions and 13 deletions
|
|
@ -63,8 +63,8 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
|
|||
user2 = insert(:user, %{local: true})
|
||||
{:ok, _user2} = User.set_activation(user2, false)
|
||||
|
||||
insert(:user, %{local: false, nickname: "u@peer1.com"})
|
||||
insert(:user, %{local: false, nickname: "u@peer2.com"})
|
||||
insert(:instance, host: "peer1.com")
|
||||
insert(:instance, host: "peer2.com")
|
||||
|
||||
{:ok, _} = Pleroma.Web.CommonAPI.post(user, %{status: "cofe"})
|
||||
|
||||
|
|
@ -83,8 +83,9 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
|
|||
end
|
||||
|
||||
test "get peers", %{conn: conn} do
|
||||
insert(:user, %{local: false, nickname: "u@peer1.com"})
|
||||
insert(:user, %{local: false, nickname: "u@peer2.com"})
|
||||
# Peers come from the instances table, which remote users add to.
|
||||
insert(:instance, host: "peer1.com")
|
||||
insert(:instance, host: "peer2.com")
|
||||
|
||||
Pleroma.Stats.force_update()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue