Postgres 9.2 – The Database You Helped Build
postgres.heroku.com
postgres.heroku.com
At one point I got scared by the prospect that I might be an expert on Postgres on AWS, because frankly I didn't know all that much about it and thought we were doomed if that was really the case.
Then I went over had lunch with the Heroku team, and it was eye opening. These guys truly knew how to run Postgres on AWS (and presumably still do).
I can't think of another org that is moving Postgres on AWS forward better than Heroku.
It's a balancing act between max_connections and shared_buffers. Each instance type will have a sweet spot for your use case -- you'll have to find it through experimenting.
Read this: http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Serve...
And this: http://www.postgresql.org/docs/9.2/static/kernel-resources.h...
Give as much RAM to Postgres as possible -- let it do the memory management. Sometimes going to an instance with double the RAM will give you more than double the performance.
No swap on the box. The moment you hit swap you're screwed.
Vacuum often, maybe continuously, if the database has a lot of updates or deletes. Do your capacity planning so you can vacuum all the time.
I'll update if I think of more.
Wrong.
...some common myths:
1. Swap space does not inherently slow down your system. In fact, not having swap space doesn't mean you won't swap pages. It merely means that Linux has fewer choices about what RAM can be reused when a demand hits. Thus, it is possible for the throughput of a system that has no swap space to be lower than that of a system that has some.
2. Swap space is used for modified anonymous pages only. Your programs, shared libraries and filesystem cache are never written there under any circumstances.
3. Given items 1 and 2 above, the philosophy of “minimization of swap space” is really just a concern about wasted disk space. ...
http://www.linuxjournal.com/article/10678
Edit: formatting
It seems like there are two potential situations here: 1/ You have swap, you hit swap. Massive slowdown. 2/ You don't have swap, run out of memory and processes die.
#1 is not a good situation, but it seems preferable to #2 doesn't it?
At this point, I think running your own data infrastructure is like having a generator in your garage instead of using the power grid.
More visibility would be greatly appreciated into what you're doing behind the scenes and increase your customers' confidence and expectations of using the Heroku pg cloud service. I hope you provide more depth to future answers as opposed to, "Just trust us". I've found that in practice, things never work out that way.
Reddit obviously is a different scenario, but most people don't work at Reddit.
I haven't had a chance to finish it. But it does look like the author knows what he's talking about.
And now it does :)
But my use case is the opposite: I am storing exactly the data coming from external APIs.
My table has some fields I already extracted from the JSON data, cause I need them now, yet I don't want to throw away the full data, as I may need it in the future.
So, I was storing the original JSON as text.
But, having support for the API format in the db itself is much better, as I can also actually query and manipulate this data without pulling all the text fields in my client code.
https://devcenter.heroku.com/articles/upgrade-heroku-postgre... has information about the upgrade process.