# Does Discourse require 2GB to work "Lag Free"?

**URL:** https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278
**Category:** Feature
**Created:** [16 בפברואר,‏ 2015,‏ 5:41am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278 "2015-02-16T05:41:21Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![nahtnam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nahtnam/32/122073_2.png) [@nahtnam](https://meta.discourse.org/u/nahtnam)
#### Post date: [16 בפברואר,‏ 2015,‏ 5:41am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/1 "2015-02-16T05:41:21Z")

</div>

In my opinion, we should be working on improving the performance of Discourse rather than working on adding more features. I find it ridiculous that for Discourse to work lag free we have to use a 2gb server, whereas using something like SMF barely requires 512mb. Just my two cents.

---

<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: [16 בפברואר,‏ 2015,‏ 6:01am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/2 "2015-02-16T06:01:27Z")

</div>

I work pretty extensively on performance and am quite proud of where Discourse is at the moment.

At this point pushing memory requirements down would require either

1. Building support for JRuby so we can get native threading, which would fragment our development. Not that I am against it but it is very complex. Even then it is questionable if JRuby would be able to work nicely with say 250MB total. I don’t know.
2. Building native threading into MRI Ruby, that would take multiple years of full time work for the entire team.
3. Porting all of Discourse to another platform like say golang. Another multiple year project.
4. Running a threaded web server that like puma, which is only sort of threaded due to the GIL and would be more glitchy.

None of the options sound too appealing to me so the 1GB requirement is going to have to remain for now.

Its the nature of the beast, if you want to build a big Ruby app it will consume a lot of memory, we continue to work on reducing memory requirements but it takes time and is not something we can all work on.

When it comes to performance on my immediate roadmap is:

- Improve client side rendering of topics
- Improve how Discourse works with gigantic databases.

---

<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: [16 בפברואר,‏ 2015,‏ 8:54am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/3 "2015-02-16T08:54:31Z")

</div>

> [@sam](#):
>
> the 1GB requirement is going to have to remain for now

That’s not what he said.

> [@nahtnam](#):
>
> for Discourse to work lag free we have to use a 2gb server

That is what he said, which is absolutely incorrect. So really your reply here is a waste of time, since it wasn’t addressed at what was said.

We have _tons_ of clients on 1GB servers and they run fine for small and medium sites. No idea what you’re talking about.

---

<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: [16 בפברואר,‏ 2015,‏ 8:59am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/4 "2015-02-16T08:59:50Z")

</div>

I guess I was replying to:

> [@nahtnam](#):
>
> SMF barely requires 512mb

Which is a stretch and is unlikely to happen for Discourse any time soon.

---

<div class="post-metadata">

### Author: ![purldator](https://avatars.discourse-cdn.com/v4/letter/p/bcef8e/32.png) [@purldator](https://meta.discourse.org/u/purldator)
#### Post date: [16 בפברואר,‏ 2015,‏ 3:05pm UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/5 "2015-02-16T15:05:52Z")

</div>

I don’t think it ever will and I would be bold to say you shouldn’t aim for it. I think with time as technology matures it might naturally come along. Or, VPSes will be cheaper that require at least 1GB memory.

---

<div class="post-metadata">

### Author: ![steven\_yue](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/steven_yue/32/107059_2.png) [@steven\_yue](https://meta.discourse.org/u/steven_yue)
#### Post date: [16 בפברואר,‏ 2015,‏ 4:13pm UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/6 "2015-02-16T16:13:44Z")

</div>

@sam could you share some reasons why Discourse does not use `puma`?

From my experience, `puma` works better than `unicorn` even with MRI. It’s stable, and it requires less memory. Even though there is GIL, `puma` still helps the throughput a lot on I/O blocking requests situations.

I haven’t tested yet, but I think with a 1GB Discourse instance, if we switch from 2 `unicorn` worker to 1 `puma` worker with `0 - 16` thread settings, it should be able to provide similar amount of throughput, with less memory requirement.

Thanks

---

<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: [16 בפברואר,‏ 2015,‏ 10:34pm UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/7 "2015-02-16T22:34:44Z")

</div>

As I recall it has something to do with long polling but I can’t recall specifics. @sam would have to answer.

---

<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: [16 בפברואר,‏ 2015,‏ 10:37pm UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/8 "2015-02-16T22:37:43Z")

</div>

Puma is usable, in fact it is in our Gemfile. But as it stands now you would need 2 processes, one for puma and one for sidekiq, both of which would share no memory.

So that adds up to say 400MB RSS and that is even before postgres and redis.

That said, puma would be more “laggy” due to the GIL and lack of out-of-band GC. You may get similar throughput, but time per request would vary a lot more.

---

<div class="post-metadata">

### Author: ![Fabio\_Machado\_de\_Oli](https://avatars.discourse-cdn.com/v4/letter/f/48db29/32.png) [@Fabio\_Machado\_de\_Oli](https://meta.discourse.org/u/Fabio_Machado_de_Oli)
#### Post date: [28 בדצמבר,‏ 2015,‏ 12:30am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/9 "2015-12-28T00:30:54Z")

</div>

Is sidekiq replaceable?

I understand that for whoever is serious about forums it isn’t that expensive to host Discourse, but any increase in adoption leads to it getting more popular and will benefit all it’s ecosystem in the end, if I understand it correctly.

---

<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: [28 בדצמבר,‏ 2015,‏ 12:33am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/10 "2015-12-28T00:33:55Z")

</div>

Replaceable with what? There has to be some method of specifying background tasks that run for Discourse to function.

Anyway 1GB RAM works absolutely fine for most Discourse sites, we have literally dozens of $99 installs running 1GB RAM on Digital Ocean with zero issues whatsoever. You won’t need more than 1GB RAM unless your Discourse is especially large or especially active, so I’m not sure what the benefit would be of replacing Sidekiq, exactly?

---

<div class="post-metadata">

### Author: ![Fabio\_Machado\_de\_Oli](https://avatars.discourse-cdn.com/v4/letter/f/48db29/32.png) [@Fabio\_Machado\_de\_Oli](https://meta.discourse.org/u/Fabio_Machado_de_Oli)
#### Post date: [28 בדצמבר,‏ 2015,‏ 9:11am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/11 "2015-12-28T09:11:17Z")

</div>

If it works with Puma and cron jobs, would it run with 512MB?

---

<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: [28 בדצמבר,‏ 2015,‏ 9:13am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/12 "2015-12-28T09:13:32Z")

</div>

cron jobs would still require memory to boot the full rails stack, this memory would not be shared so it would be even more inefficient.

Puma + threads for bg jobs could work in ultra low memory, but performance would suffer.

---

<div class="post-metadata">

### Author: ![Fabio\_Machado\_de\_Oli](https://avatars.discourse-cdn.com/v4/letter/f/48db29/32.png) [@Fabio\_Machado\_de\_Oli](https://meta.discourse.org/u/Fabio_Machado_de_Oli)
#### Post date: [28 בדצמבר,‏ 2015,‏ 9:54am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/13 "2015-12-28T09:54:27Z")

</div>

What if a cron job makes an http request for the unicorns to process, using curl? Could it work?

---

<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: [28 בדצמבר,‏ 2015,‏ 10:00am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/14 "2015-12-28T10:00:33Z")

</div>

yeah but then you would very quickly run out of workers, unicorn is single threaded, maybe with puma, but you are describing a very complex change there.

---

<div class="post-metadata">

### Author: ![Fabio\_Machado\_de\_Oli](https://avatars.discourse-cdn.com/v4/letter/f/48db29/32.png) [@Fabio\_Machado\_de\_Oli](https://meta.discourse.org/u/Fabio_Machado_de_Oli)
#### Post date: [31 בדצמבר,‏ 2015,‏ 11:01am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/15 "2015-12-31T11:01:27Z")

</div>

I created a [question on StackOverflow](http://stackoverflow.com/questions/34534337/is-it-possible-to-run-sidekiq-in-the-same-process-with-a-puma-rails-server), and someone suggested me that [sucker\_punch](https://github.com/brandonhilkert/sucker_punch) is designed to help with this.

Do you think it’s worth investigating? Should it work?

> <https://stackoverflow.com/questions/34534337/is-it-possible-to-run-sidekiq-in-the-same-process-with-a-puma-rails-server>

---

<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: [31 בדצמבר,‏ 2015,‏ 11:05am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/16 "2015-12-31T11:05:43Z")

</div>

I can tell you Sam hates Celluloid with the fire of a thousand suns, and probably for good reason, so learning that this “sucker punch” is based on Celluloid.. I’m gonna go ahead and say ⛔

Better news is here: [Sidekiq 4.0! | Mike Perham](http://www.mikeperham.com/2015/11/16/sidekiq-4.0/) and @sam will be looking at pulling in the newer Sidekiq soon.

---

<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: [31 בדצמבר,‏ 2015,‏ 12:27pm UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/17 "2015-12-31T12:27:46Z")

</div>

That is a tad harsh, I find it a complicated abstraction that I have lots of trouble grokking.

But to be fair I have never really spent lots of time figuring it out. I am sure plenty of people are able to work with it successfully.

I am however super happy to see this big dependency is removed from sidekiq. We get a simpler, faster, easier to reason about sidekiq.

---

<div class="post-metadata">

### Author: ![pdurbin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pdurbin/32/102559_2.png) [@pdurbin](https://meta.discourse.org/u/pdurbin)
#### Post date: [25 בינואר,‏ 2016,‏ 2:33am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/18 "2016-01-25T02:33:55Z")

</div>

> [@sam](#):
>
> Porting all of Discourse to another platform like say golang. Another multiple year project.

@sam by mentioning that this would be a multi-year project, I assume you have no intention of porting Discourse from Ruby to Go, but since you mentioned Go I’m curious if you think it would have been a better choice than Ruby. I’m wondering if you’ve done any small porting experiments. Or maybe you’re really just mentioning Go in passing. It’s hard to tell from your quick comment. Anyway, I’d be curious to hear more of your thoughts on this.

---

<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: [25 בינואר,‏ 2016,‏ 3:04am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/19 "2016-01-25T03:04:45Z")

</div>

I have not done any experiments with porting stuff, I mentioned Go cause it is pretty expressive, fast and makes a pretty good platform for a JSON backend. That said the plugin story becomes significantly more complicated.

We have no plans for exploratory work in the near to medium term.

I am happy with Ruby, and what we have achieved with it. The [Ruby 3x3](http://engineering.appfolio.com/appfolio-engineering/2015/11/18/ruby-3x3) initiative makes me particularly happy, if Ruby had a better multithreading story we would drastically reduce our memory footprint.

I am not enthused about throwing everything away and switching platforms, it is not totally off the cards to introduce some microservices for read tracking and message bus (which are the lion’s share of traffic we handle)

I think it would be super interesting to have [Message Bus](https://github.com/SamSaffron/message_bus) ported to go.

---

<div class="post-metadata">

### Author: ![ljpp](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ljpp/32/96506_2.png) [@ljpp](https://meta.discourse.org/u/ljpp)
#### Post date: [25 בינואר,‏ 2016,‏ 8:11am UTC](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278/20 "2016-01-25T08:11:08Z")

</div>

I have two Discourse instances:

- One quiet forum on 1GB VPS: [http://cd-rw.org](http://cd-rw.org)
- One busy forum currently on 2GB VPS: [http://tappara.co](http://tappara.co)

They both run fine. You can potentially stretch the capabilities of a 1GB VPS by using zram, which I have done - so far so good.

With 1GB VPS slice costing 10$/month, is it really worth the effort try to push Discourse down to 512mb? I mean, what would be the expected savings - 60$ a **year**? If you have some actual traffic on your community, just add AdSense to help with the financials.

[Next page](https://meta.discourse.org/t/does-discourse-require-2gb-to-work-lag-free/25278.md?page=2)
