# Long message-bus HTTP requests? What are they for?

**URL:** https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241
**Category:** Support
**Created:** [2017年五月7日 06:02 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241 "2017-05-07T06:02:57Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![Yassine\_Yousfi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yassine_yousfi/32/195913_2.png) [@Yassine\_Yousfi](https://meta.discourse.org/u/Yassine_Yousfi)
#### Post date: [2017年五月7日 06:02 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/1 "2017-05-07T06:02:57Z")

</div>

I was doing tons of efforts to optimize my website, and while checking the performance reports, for tons of pages (including the home page). I could find that it gives these two “poll” requests that are taking too long to load, Is it a Poll plugin being loaded 😕 though non of those pages have the poll plugin in them being used 😕 and the user loading is anonymous.

Any insights would be appreciated, Thanks

 ![](https://global.discourse-cdn.com/meta/original/3X/b/4/b4d3a565989e8a5d1c20109e065ece32d062dd4f.png)

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2017年五月7日 06:10 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/2 "2017-05-07T06:10:38Z")

</div>

No, it isn’t the poll plugin. What poll means in this context is kinda like “check the server to see what’s new since the last time checked” and then send it over in the “message bus”

AFAIK this runs every 30 seconds but I have never seen anybody here having a problem with it coming back slow.

Running some kind of unique set up?  
Is the .3 seconds causing a noticeable problem for you?

---

<div class="post-metadata">

### Author: ![Yassine\_Yousfi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yassine_yousfi/32/195913_2.png) [@Yassine\_Yousfi](https://meta.discourse.org/u/Yassine_Yousfi)
#### Post date: [2017年五月7日 06:13 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/3 "2017-05-07T06:13:50Z")

</div>

nop, not unique setup at all…  
and it’s not slowing down the website that much, but it’s being the slowest for sure. and made me wonder how really important it is. and whether or not can sacrifice it.

You’ve said it takes 30 seconds everytime, though those stats are from pingdome, and it’s just a single call the full time to load everything is around 300ms at the moment. and poll is being called twice at least during that time (or at a single call to the page).

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2017年五月7日 06:18 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/4 "2017-05-07T06:18:35Z")

</div>

It doesn’t take 30 seconds, it _runs_ every 30 seconds.

You can’t really do without it. A lot of “updated information” is sent back. Notifications, new topics, post counts, posts themselves.

---

<div class="post-metadata">

### Author: ![Yassine\_Yousfi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yassine_yousfi/32/195913_2.png) [@Yassine\_Yousfi](https://meta.discourse.org/u/Yassine_Yousfi)
#### Post date: [2017年五月7日 06:20 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/5 "2017-05-07T06:20:54Z")

</div>

Yep I totally understand 🙂

Since as mentioned it’s being called **Twice** on the initial page load, wouldn’t it make more sense to load fresh page (with all notifications, topics…Etc) on the first call. and then wait 30s before making another call to it?!

Or at least if it’s limited by the structure on wish discourse has been programmed on (which I believe it doesn’t), then a single poll call would just do.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2017年五月7日 06:26 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/6 "2017-05-07T06:26:47Z")

</div>

The initial page load is typically the most expensive (exception maybe being an image heavy topic) because essentially the entire app is getting loaded. After that it’s the “live update” stuff.  
Subsequent pages do not load in the entire app again.

---

<div class="post-metadata">

### Author: ![Yassine\_Yousfi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yassine_yousfi/32/195913_2.png) [@Yassine\_Yousfi](https://meta.discourse.org/u/Yassine_Yousfi)
#### Post date: [2017年五月7日 06:33 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/7 "2017-05-07T06:33:54Z")

</div>

Yep, exactly.

That’s exactly what I love about discourse, I know now that my initial web call takes 300ms, that means any subsequent call will take way much less. which is nice.

Thanks for your feedback @Mittineague 🙂

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2017年五月7日 12:04 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/8 "2017-05-07T12:04:09Z")

</div>

Note that these requests will not slow down your website _at all_, since nothing is waiting for them!  
They are simple a way to keep an open connection to the server to implement push messages 🙂

---

<div class="post-metadata">

### Author: ![Yassine\_Yousfi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yassine_yousfi/32/195913_2.png) [@Yassine\_Yousfi](https://meta.discourse.org/u/Yassine_Yousfi)
#### Post date: [2017年五月7日 12:17 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/9 "2017-05-07T12:17:53Z")

</div>

Yep, they aren’t pausing the load.

Though I’ve noticed on the home page, when it’s loading those hundreds of user avatars, Discourse only allows a limited number of parallel loads, which causes for other requests to wait;

Maybe that can be increased as well, but It can lead to someone to abuse it costing me more server resources.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [2017年五月7日 12:18 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/10 "2017-05-07T12:18:38Z")

</div>

I believe that is a browser / OS limitation, but I’m not sure.

---

<div class="post-metadata">

### Author: ![Yassine\_Yousfi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yassine_yousfi/32/195913_2.png) [@Yassine\_Yousfi](https://meta.discourse.org/u/Yassine_Yousfi)
#### Post date: [2017年五月7日 12:19 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/11 "2017-05-07T12:19:34Z")

</div>

pingdom says it’s from server side. but not sure as well.

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [2017年五月8日 05:12 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/12 "2017-05-08T05:12:26Z")

</div>

It’s “from server side” insofar as the server controls the fact that all requests are all going to the same domain, however it’s the browser that decides to make no more than N connections to the server in parallel. Since that’s never going to get fixed, just switch to using HTTP/2 (it _should_ be built-in, as long as you’re using TLS) and everything will be much, much better.

---

<div class="post-metadata">

### Author: ![Yassine\_Yousfi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yassine_yousfi/32/195913_2.png) [@Yassine\_Yousfi](https://meta.discourse.org/u/Yassine_Yousfi)
#### Post date: [2017年五月8日 08:38 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/13 "2017-05-08T08:38:42Z")

</div>

thanks @mpalmer for your contribution, but could you please elaborate or give links.. concerning this point below:

> just switch to using HTTP/2 (it should be built-in, as long as you’re using TLS) and everything will be much, much better.

---

<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: [2017年五月8日 14:20 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/14 "2017-05-08T14:20:44Z")

</div>

You can read about MessageBus here:

> [@How discourse stays online (Message Bus, Faye, Long Polling)](https://meta.discourse.org/t/how-discourse-stays-online-message-bus-faye-long-polling/3238/7):
>
> I wrote the message bus so I should answer this. However, before I answer anything let me explain the message bus. (in ruby code on the server) # publish the string norris to a channel called /chuck MessageBus.publish('/chuck', 'norris') # publish the string 'secret' to a channel called /check, but only to these particular user\_ids MessageBus.publish('/chuck', 'norris', user\_ids: [1,2,3]) # subscribe to the channel '/chuck' on the server MessageBus.subscribe('/chuck') do |msg| # yay, I …

[MessageBus](https://github.com/SamSaffron/message_bus) is responsible for pushing live notifications from the server to the clients.

So, for example, as soon as someone ❤'s this message I get a blue notification on the top right. Or if someone replies this page will refresh right away with the reply.

MessageBus using long polling with chunked encoding, what this means is that a single 30 second session can push multiple messages from the server to the client.

The 30 second requests here are not a performance concern, payloads are tiny and the server is designed to handle this traffic very easily. Since you are using H2 it does not even eat up a connection slot like it would in the old days of H1. Once browser moves to a background tab message bus is smart enough to slow down its polling.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2019年六月3日 05:10 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/15 "2019-06-03T05:10:18Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2019年七月3日 05:10 UTC](https://meta.discourse.org/t/long-message-bus-http-requests-what-are-they-for/62241/16 "2019-07-03T05:10:22Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
