# Posting is taking multiple seconds

**URL:** https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505
**Category:** Support
**Created:** [May 13, 2020, 12:04am UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505 "2020-05-13T00:04:30Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [May 13, 2020, 12:04am UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/1 "2020-05-13T00:04:30Z")

</div>

We have 5M posts and searching is pretty snappy. Hosting on a 6 shared vcores of a 2.8Ghz Xeon E5-2680 with 16GB RAM and SSD storage. That said I don’t have metrics on how many simultaneous posts our users initiate, there might be locking issues.

_Posting,_ on the other hand, is often quite slow. It can take 6-7 seconds for a post to go through. Discourse is non-blocking when it chugs away so that doesn’t kill the user experience, though.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 13, 2020, 6:47am UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/2 "2020-05-13T06:47:35Z")

</div>

> [@Wingtip](#):
>
> It can take 6-7 seconds for a post to go through.

This is.. not normal.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 13, 2020, 7:03am UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/3 "2020-05-13T07:03:14Z")

</div>

I think this is most likely the case on any topic with 100s or 1000s of posts. On short topics this should not be the case.

I recall @Wingtip’s forum has tons of very long topics.

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [May 13, 2020, 1:04pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/4 "2020-05-13T13:04:21Z")

</div>

Yes, we definitely do.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 13, 2020, 4:04pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/5 "2020-05-13T16:04:11Z")

</div>

Are the 6-7 second post times specific to the mega topics? If you reply to a topic with 100 replies, does it also take 6-7 seconds?

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [May 13, 2020, 4:16pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/6 "2020-05-13T16:16:05Z")

</div>

I was unable to reproduce just now-- slow posting is intermittent. It doesn’t seem to correlate with post count in the thread. Maybe it’s a locking issue with someone else posting simultaneously or something.

7 posts = very fast, roughly the same as here on meta  
500 posts = maybe slightly slower, not too bad. Maybe 1.5 second?  
16k posts = seems about the same as with 500

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 13, 2020, 5:08pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/7 "2020-05-13T17:08:40Z")

</div>

And I believe that performance is also affected if a bunch of people are accessing a mega topic, which slows down the whole PG server with queued requests.

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [May 13, 2020, 5:10pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/8 "2020-05-13T17:10:15Z")

</div>

That makes sense, to prioritize the experience of many people viewing a thread over one or two trying to post.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [May 14, 2020, 7:58am UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/9 "2020-05-14T07:58:56Z")

</div>

How brave are you feeling? Do you mind enabling mini\_profiler for a bit? It will give you timings on the side, then we can isolate which query is playing up for you!

My post here took 576ms

 ![image](https://global.discourse-cdn.com/meta/original/3X/2/4/24ab09ca07587b19c53a41c4a077b2d02ef36f78.png)

The worst query is:

 ![image](https://global.discourse-cdn.com/meta/original/3X/5/6/56772e067f765a5edc9aadbb917b12c188a6467c.png)

And @riking is working on a PR that will fix this 🎊

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [May 14, 2020, 11:41am UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/10 "2020-05-14T11:41:32Z")

</div>

How much does enabling it impact overall performance? And can it be enabled without a site rebuild? I haven’t been able to get a rebuild to succeed since the postgres 12 change, even by setting it to stick with pg10.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 14, 2020, 12:49pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/11 "2020-05-14T12:49:04Z")

</div>

You need to set your email address as the developer email in the app.yml file. You can apply it without a rebuild by destroying and restarting the container. It you have made changes to the container, by upgrading with discourse docker they will be lost.

You can also edit config/discourse conf inside the container and then

```
  sv restart unicorn

```

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [May 14, 2020, 1:05pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/12 "2020-05-14T13:05:55Z")

</div>

Given that rebuilds are failing, my concern is if I destroy the container I’ll be completely out of luck. Had so many errors with attemping the pg12 upgrade yesterday that I’m really not comfortable making changes until I have confidence I won’t take the site down for an extended period.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 14, 2020, 3:14pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/13 "2020-05-14T15:14:46Z")

</div>

Well, free advice is worth what you pay for it, but it’s pretty safe to

```plaintext
cd /var/discourse
./launcher enter app
vi config/discourse.conf
# in vi, edit the developer_emails line to have your email address and quit vi
sv unicorn restart
# panic for the 30-90 seconds it takes the web server to restart and begin serving pages

```

You can still break things this way, though. I think it’s possible to muck up that config file such that discourse won’t start.

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [May 14, 2020, 3:21pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/14 "2020-05-14T15:21:07Z")

</div>

`sv restart unicorn` worked, `sv unicorn restart` did not.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 14, 2020, 3:25pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/15 "2020-05-14T15:25:09Z")

</div>

I get that backward about 1/3 of the time. 😉

This is an improvement, though, as I used to get it wrong half the time.

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [May 14, 2020, 3:25pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/16 "2020-05-14T15:25:34Z")

</div>

Is this what you needed? This is posting to a thread with 16k posts. This seemed like a normal post time, not particularly slow.

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/d/cde1c271bf264032f09908c588f723b0d6c9cad6.png)

Here’s the full output:  
[https://paste.mozilla.org/f5nJrPag](https://paste.mozilla.org/f5nJrPag)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [May 14, 2020, 4:04pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/17 "2020-05-14T16:04:22Z")

</div>

It’s a 2s query coming from app/models/user\_stat.rb:159:in `update\_topic\_reply\_count’.

So it’s the exact thing @riking is working on.

---

<div class="post-metadata">

### Author: ![Wingtip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wingtip/32/102039_2.png) [@Wingtip](https://meta.discourse.org/u/Wingtip)
#### Post date: [May 14, 2020, 4:12pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/18 "2020-05-14T16:12:34Z")

</div>

Great! Any substantial improvements to post time will really make our users happy, this is the most complained-about thing at the moment. Although I have no doubt they’ll find something else to whine about shortly thereafter.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 14, 2020, 9:01pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/19 "2020-05-14T21:01:37Z")

</div>

If it makes you feel any better, I complained about that query as well, because I have so much read state here on meta. We’re doing pointless work to count stuff on every reply…

---

<div class="post-metadata">

### Author: ![Ghan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ghan/32/177964_2.png) [@Ghan](https://meta.discourse.org/u/Ghan)
#### Post date: [May 14, 2020, 9:06pm UTC](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505/20 "2020-05-14T21:06:48Z")

</div>

In our test import from another software, we have a topic with a bit over 200,000 posts and I was able to post to it just fine. It must be because it’s not the topic size that matters, but rather the user who is doing the posting.

[Next page](https://meta.discourse.org/t/posting-is-taking-multiple-seconds/151505.md?page=2)
