Commit 2c343021 authored by Joe Oblivian's avatar Joe Oblivian Committed by agata
Browse files

Performance tweaks:

- Cache more aggressively
- Use persistent connections

Profiling: changing the define AI_DB_PROFILER to true will enable query logging (use with caution!)
parent f2ba1797
...@@ -7,6 +7,9 @@ RewriteCond %{HTTP_HOST} ^ventitre\.noblogs\.org [NC] ...@@ -7,6 +7,9 @@ RewriteCond %{HTTP_HOST} ^ventitre\.noblogs\.org [NC]
RewriteRule ^/?(.*) http://www.ventitre.org/$1 [L,R=301,NE] RewriteRule ^/?(.*) http://www.ventitre.org/$1 [L,R=301,NE]
#### ####
#avoid inspection of queries log
RewriteRule ^/noblogs_queries.* /ancheno [L,R=404]
# uploaded files # uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L] RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
RewriteRule ^gallery/([0-9]+)/(previews|previews-med)/(.*)$ oldgal/$1/$2/$3 [L] RewriteRule ^gallery/([0-9]+)/(previews|previews-med)/(.*)$ oldgal/$1/$2/$3 [L]
...@@ -17,7 +20,8 @@ RewriteRule ^resource/[^/]+/download/(.*)$ wp-includes/ms-files.php?file=2010/08 ...@@ -17,7 +20,8 @@ RewriteRule ^resource/[^/]+/download/(.*)$ wp-includes/ms-files.php?file=2010/08
# BEGIN WPSuperCache # BEGIN WPSuperCache
<IfModule mod_rewrite.c> <IfModule mod_rewrite.c>
AddDefaultCharset UTF-8 AddDefaultCharset UTF-8
RewriteCond %{REQUEST_URI} !^.*[^/]$ # Commented in order to cache more
# RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$ RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.* RewriteCond %{QUERY_STRING} !.*=.*
...@@ -31,7 +35,8 @@ RewriteCond %{HTTP:Accept-Encoding} gzip ...@@ -31,7 +35,8 @@ RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/%{HTTP:X-Forwarded-Proto}/$1/index.html.gz -f RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/%{HTTP:X-Forwarded-Proto}/$1/index.html.gz -f
RewriteRule ^(.*) "/wp-content/cache/supercache/%{HTTP_HOST}/%{HTTP:X-Forwarded-Proto}/$1/index.html.gz" [L] RewriteRule ^(.*) "/wp-content/cache/supercache/%{HTTP_HOST}/%{HTTP:X-Forwarded-Proto}/$1/index.html.gz" [L]
RewriteCond %{REQUEST_URI} !^.*[^/]$ #Commented in order to cache more
#RewriteCond %{REQUEST_URI} !^.*[^/]$
RewriteCond %{REQUEST_URI} !^.*//.*$ RewriteCond %{REQUEST_URI} !^.*//.*$
RewriteCond %{REQUEST_METHOD} !POST RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{QUERY_STRING} !.*=.* RewriteCond %{QUERY_STRING} !.*=.*
......
<?php <?php
// Common settings // Common settings
$wpdb->save_queries = false; $wpdb->persistent = true;
$wpdb->persistent = false;
$wpdb->max_connections = 30; $wpdb->max_connections = 30;
define("NOBLOGS_BACKEND_CONFIG", "/etc/noblogs/backends"); define("NOBLOGS_BACKEND_CONFIG", "/etc/noblogs/backends");
...@@ -22,4 +21,3 @@ $wpdb->add_database(array( ...@@ -22,4 +21,3 @@ $wpdb->add_database(array(
)); ));
$wpdb_reverse_backend_map = noblogs_load_backends(NOBLOGS_BACKEND_CONFIG, $wpdb->hash_map); $wpdb_reverse_backend_map = noblogs_load_backends(NOBLOGS_BACKEND_CONFIG, $wpdb->hash_map);
<?php <?php
//AI patch: set to true if you want to activate query profiling
define('AI_DB_PROFILER', false);
/* /*
Plugin Name: HyperDB Plugin Name: HyperDB
...@@ -1441,6 +1443,23 @@ class hyperdb extends wpdb { ...@@ -1441,6 +1443,23 @@ class hyperdb extends wpdb {
} // class hyperdb } // class hyperdb
$wpdb = new hyperdb(); /**
* AI custom: Logs all queries for debugging purposes
*/
function ai_log_db_queries($query, $time, $backtrace=null, hyperdb $obj ) {
$fh = fopen( ABSPATH . '/profiling/noblogs_queries_'. date('Ymd') . '.log', 'a');
if (!$fh) {
return array($query, $time, $backtrace);
}
fwrite($fh, sprintf("##\n#Date: %s\n#Query time: %s\n%s\n", date('r'), $time, $query));
fclose($fh);
return array($query, $time, $backtrace);
}
$wpdb = new hyperdb();
if ( AI_DB_PROFILER === true ) {
$wpdb->save_queries = true;
$wpdb->save_query_callback = 'ai_log_db_queries';
}
require( DB_CONFIG_FILE ); require( DB_CONFIG_FILE );
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment