1
Xman04
Queries, database connections, and cache settings
  • 2006/1/8 5:44

  • Xman04

  • Not too shy to talk

  • Posts: 180

  • Since: 2004/7/12


I was noticing that one of the themes displays the number of queries that are run each time a page is loaded. I was playing around with the cache features, and reduced the home page queries from 52 to around 20. Basically, I'm trying reduce the number of times that the database is accessed and reduce the resources utilized by the CPU. The goal being to minimize resource consumption, to avoid my shared server account from slowing down or locking up during traffic surges.

I have a question about this. With most shared server plans, there is a limit to concurrent MySQL user connections. My particular plan has a 15 user limit, meaning that if 16 users access the database server at the exact same time, then the 16th user will receive an error message. Ok here is my question: When a user accesses my home page, are those 20 queries considered to be occurring under one user connection? Or is there ever a situation where a set of queries (initiated by the same user) are issued through multiple connection requests? I'm hoping that isn't the case, given the limit of 15 concurrent connections.

One other question. Has anyone set a short cache (example: a 30 second cache) to their forum? I'm thinking that maybe a 30 second cache will allow me to run a somewhat busy forum, without the 15 user connection limit being a problem (at low to moderate levels of traffic). My only concern would be the lag in new posts appearing because of the 30 second cache. I'm just trying to figure out a way to squeeze as much as I can out of a shared server, before being forced to upgrade to a VPS, semi-dedicated, or dedicated server.

Dave

2
guardian2k1
Re: Queries, database connections, and cache settings

Quote:

Xman04 wrote:
I was noticing that one of the themes displays the number of queries that are run each time a page is loaded. I was playing around with the cache features, and reduced the home page queries from 52 to around 20. Basically, I'm trying reduce the number of times that the database is accessed and reduce the resources utilized by the CPU. The goal being to minimize resource consumption, to avoid my shared server account from slowing down or locking up during traffic surges.

I have a question about this. With most shared server plans, there is a limit to concurrent MySQL user connections. My particular plan has a 15 user limit, meaning that if 16 users access the database server at the exact same time, then the 16th user will receive an error message. Ok here is my question: When a user accesses my home page, are those 20 queries considered to be occurring under one user connection? Or is there ever a situation where a set of queries (initiated by the same user) are issued through multiple connection requests? I'm hoping that isn't the case, given the limit of 15 concurrent connections.

One other question. Has anyone set a short cache (example: a 30 second cache) to their forum? I'm thinking that maybe a 30 second cache will allow me to run a somewhat busy forum, without the 15 user connection limit being a problem (at low to moderate levels of traffic). My only concern would be the lag in new posts appearing because of the 30 second cache. I'm just trying to figure out a way to squeeze as much as I can out of a shared server, before being forced to upgrade to a VPS, semi-dedicated, or dedicated server.

Dave


I don't quite understand the first question as limiting the number of queries to a database would seriously hamper any site design. Unfortunately I don't know enough about shared hosting to answer that question accurately.

As for the forum, caching is a really bad idea and should be avoided. Check wolf factorys Caching guide for tips. We currently host our site on a shared server and by using this guide and searching through the forums we were able to dramatically increase the performance of xoops.:)
"Linux is extremely user-friendly. It also happens to be extremely selective when picking its friends."

http://www.nuxified.com | http://debcentral.org

3
Xman04
Re: Queries, database connections, and cache settings
  • 2006/1/9 17:00

  • Xman04

  • Not too shy to talk

  • Posts: 180

  • Since: 2004/7/12


Hi guardian2k1,

You said:
Quote:
I don't quite understand the first question as limiting the number of queries to a database would seriously hamper any site design. Unfortunately I don't know enough about shared hosting to answer that question accurately.


I reread my first post, and it is very confusing the way I asked my first question. I apologize for that.

I'm not worried about any hampering of the site design. I'm primarily wondering how and when XOOPS attempts to make database connections. For example, when a user first loads my home page, if 20 database queries are run during the page load for that user, will the 20 queries count as one user connection? Or, does XOOPS connect and then disconnect for each query that is run? In other words, does 20 queries = 20 connections? I'm assuming that this isn't the case, but I'm not completely sure.

The reason I'm asking this question is because many of the shared hosting plans have a limitation on simultaneous database connections. My plan has a limitation of 15 concurrent connections. Thus, if each query is a connnection (rather than each user generated set of queries equaling one connection), then the connection limitations will be that much more of a problem when managing the limited resources on a shared plan.

I'm using caching, and that reduces the quantity of queries very significantly. I'm very happy with that, since it will boost performance. However, the database connection limitations with shared web hosts is still worrying me. The caching helps a lot, but there is still a significant quantity of queries that are run even with efficient caching.

You said:
Quote:
As for the forum, caching is a really bad idea and should be avoided. Check wolf factorys Caching guide for tips. We currently host our site on a shared server and by using this guide and searching through the forums we were able to dramatically increase the performance of xoops.:)


I agree that it is not an ideal situation to cache a forum, even for 30 seconds. Although, for very busy forums on shared servers, a notice could be posted that new posts will not appear for 30 seconds. That still may be very annoying to users though. And, I'm not really sure what other weird affects may occur with a forum cache. I guess I would have to test and observe, which I may do.

My only reason for considering a forum cache is to prevent reaching the database connection limitations of the shared hosting plans, since forums often generate the most concurrent traffic. If the forum is very busy and on a shared server, then there could be many database connecton errors generated. A 30 second cache may reduce this problem quite a bit. It would be nice if there were even shorter caches available, such as a 10 or 15 second cache, which may go a long way in preventing the limitations from being reached (and not annoying users too much).

Anyway, if I experiment with forum caching, then I will let everyone know how it works out.

Dave

Login

Who's Online

451 user(s) are online (79 user(s) are browsing Support Forums)


Members: 0


Guests: 451


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits