Email or username:

Password:

Forgot your password?
Matt Baer

I'm looking for a little help working through some database scaling issues with #WriteFreely.

On our Write.as instance, we're up to 4.25 million rows in our `posts` table, and it's causing problems for some individual blogs with 9,000+ posts.

I have an idea of what some bottleneck queries are. But wondering if there are easy db optimizations we might make (indexes, etc.), and if anyone can help identify what they might be.

Boosts appreciated!

9 comments | Expand all CWs
Ben Zanin

@matt hmm, it might be easier to have a structured conversation investigation perf issues in a forum where it's easier to share log files and the like. Is there a github issue tracking this already?

Red Ogre Review

@matt

It might not be a quick fix, but spinning off older entries into their own quasi-archive tables could help, especially if they're ones that are rarely accessed. You'd need a routing mechanism somewhere to detect when to jump from the main table to the archives.

And do you have something like Redis in place for caching common / recent queries? That could help for material that's frequently accessed but doesn't change often.

immibis
@matt if you know what the slow queries are, it's often not difficult to see which indices would help - assuming the queries are quite simple.
DELETED

@matt if you haven't already, turn on slow query logging, it will expose the problem queries and you can tune indexes from there. You didn't mention the DB engine you are using, but MySQL can be an absolute nightmare to do this, I do it all the time.

Berkubernetus

@matt Unfortuantely I know nothing about your stack or your code (other than it being MySQL-backed). However, here's the general troubleshooting lists of things that make a database-backed web application slow:

1. Too many queries: app is pulling lots of things from the DB constantly that could be cached, or doing joins in the app code

2. Unoptimized requests: some DB requests need better queries/better data structure/indexes

...

Berkubernetus

@matt ... both of the above could be found via query logs and metrics.

3. Inadequate hardware: if your DB is 150GB and you have 1GB of RAM, you will always be trying to fight performance.

4. Locking: app is designed so that some requests block other requests.

5. Misconfiguration: DB, platform, or other parts of the stack are configured in a way that limits throughput.

...

Berkubernetus

@matt ... if this were Postgres, I could give you some queries to hunt for tables that need indexes, but it's not. Hopefully some MySQL folks will speak up with the same.

Go Up