This is probably the link you are looking for: http://www.webtatic.com/packages/php54/
This one will save you a lot of hours dealing with old PHP 5.3 and newest MySQL 5.6 incompatibilities.
News, Personal view and perspective of the software performance field, cloud computing and industry based on my experience
Apr 9, 2013
Mar 19, 2013
My MongoDB and PHP Famous 5 Minutes Tutorial
Did you ever wanted to integrate MongoDB monitoring with a third party service?
Did you wanted to integrate MongoDB performance counters with your load stress environment?
This 5 minutes tutorial will help you expose these details to any third party service or application using a simple JSON service, PHP and MongoDB:
Did you wanted to integrate MongoDB performance counters with your load stress environment?
This 5 minutes tutorial will help you expose these details to any third party service or application using a simple JSON service, PHP and MongoDB:
- Install Apache and PHP and php-devel: sudo yum -y install httpd php php-devel php-pear
- Install PHP MongoDB Driver: sudo pecl install mongo
- Add extension=mongo.so to you /etc/php.ini
- Create a short monitoring code as mongo.php and place it at /var/www/html/:
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json;charset=UTF-8');
class Monitor {
public $VirtualMemory_MB;
public $PageFaults;
public $CurrentConnections;
public $NetworkIO_In_MB;
public $NetworkIO_Out_MB;
public $SpeedIO_Avg_ms;
public $LockRatio_Per;
public $ReadersLocked;
public $WritersLocked;
public $ObjectsInDatabase;
public $DatabaseDataSize_MB;
public $DatabaseIndexSize_MB;
public $IndexMissRatio_Per;
public $CursorsTimedOut;
public $DeleteSelectRatio_Per;
public $InsertSelectRatio_Per;
public $UpdateSelectRatio_Per;
}
if (!isset($_REQUEST['db'])) {
header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
echo json_encode(array('status'=>0,'message'=>'db is missing'));
exit;
}
$databaseName = $_REQUEST['db'];
// connect
$m = new MongoClient();
// select a database
$db = $m->$databaseName;
$ret = $db->execute('db.stats();');
$result = new Monitor;
$result->ObjectsInDatabase = $ret["retval"]["objects"];
$result->DatabaseDataSize_MB = $ret["retval"]["dataSize"];
$result->DatabaseIndexSize_MB = $ret["retval"]["indexSize"];
//var_dump($ret);
$ret = $db->execute('db.serverStatus();');
$result->VirtualMemory_MB = $ret["retval"]["mem"]["virtual"];
$result->PageFaults = $ret["retval"]["extra_info"]["page_faults"];
$result->CurrentConnections = $ret["retval"]["connections"]["current"];
$result->NetworkIO_In_MB = $ret["retval"]["network"]["bytesIn"]/1000000;
$result->NetworkIO_Out_MB = $ret["retval"]["network"]["bytesOut"]/1000000;
$result->SpeedIO_Avg_ms = $ret["retval"]["backgroundFlushing"]["average_ms"];
$result->LockRatio_Per = $ret["retval"]["globalLock"]["lockTime"]/$ret["retval"]["globalLock"]["totalTime"]*100;
$result->ReadersLocked = $ret["retval"]["globalLock"]["currentQueue"]["readers"];
$result->WritersLocked = $ret["retval"]["globalLock"]["currentQueue"]["writers"];
$result->IndexMissRatio_Per = $ret["retval"]["indexCounters"]["btree"]["missRatio"];
$result->CursorsTimedOut = $ret["retval"]["cursors"]["timedOut"];
$result->DeleteSelectRatio_Per = $ret["retval"]["opcounters"]["delete"]/$ret["retval"]["opcounters"]["query"]*100;
$result->InsertSelectRatio_Per = $ret["retval"]["opcounters"]["insert"]/$ret["retval"]["opcounters"]["query"]*100;
$result->UpdateSelectRatio_Per = $ret["retval"]["opcounters"]["update"]/$ret["retval"]["opcounters"]["query"]*100;
echo json_encode($result);
?>
Bottom Line
You MongoDB is ready for monitoring by an external service: http://localhost/mongo.php
Keep Performing,
Mar 6, 2013
mongoDB Insider Tips
This time I would like to share with you several insider tips that can be used to better understand mongoDB and its internals.
Bottom Line
Memory Limitation:
No, mongoDB does not support it (very similar to SQL Server before adjusting the memory
limitations):
Virtual memory and resident sizes may appear
to be very large for the mongod process. This is by design: virtual memory space should be just larger than the size of the data files open and mapped. Resident
size will vary depending on the amount of memory not used by other processes on
the machine. Yes, if you allocate more memory to the machine, mongoDB will happily consume it,
mongoDB defines its storage size. You can compact
it.
Mongo tends to preallocate a significant size
of disk.
If your data store is too large you may use the
following commands to reduce it:
Use ext4 file system
When ext3 is used and mongoDB allocates new
data files, these files have to be filled with zeroes that are written back to the
underlying disk (yes, extra unneeded writes to disk).
When ext4 or xfs are used, mongoDB
uses the falloc syscall that marks the file as allocated and zeroed, without actually writing
anything back to the underlying storage. The result is a better insert
performance on ext4 than ext3.
Quorum is for voting, data replication is async
by default.
Unlike Cassandra, mongoDB uses Quorum only for
primary server selection. Write is done only to primary server and answer is returned to the client immediately. The secondary servers
(or some will say the slaves) copy the data in async way.
Synchronous replication is possible but not recommended: Query response to user can be delayed to
ensure that data was replicated to slaves. However it may result with 2 orders of
magnitude performance decrease:
mongoDB stores data as BSON and communicates in
JSON
BSON or JSON? This is not a question anymore, as
mongoDB these days automatically serialize the JSONs into BSONs to save space
on disk.
Now that you better understand the mongoDB architecture, it is time to make more out of it,
Keep Performing,
Mar 5, 2013
Some Best Practices for your Next MySQL Installation with SSD
Do you plan on installing a new MySQL server?
Did you ask yourself what is the best file system for it?
What modification are recommended?
What MySQL version to use?
Do you consider using SSD?
You got to the right place.
Linux, SSD and MySQL. The Best Practices
Bottom Line
Few decisions can enhance your MySQL performance. Make your decisions right.
Keep Performing,
Moshe Kaplan
Did you ask yourself what is the best file system for it?
What modification are recommended?
What MySQL version to use?
Do you consider using SSD?
You got to the right place.
Linux, SSD and MySQL. The Best Practices
- Up to date CentOS (6.3). MySQL RPM are easily available for this platform w/o the need to compile them.
- ext4 file system. It is has some goodies over ext3 and is even more recommended if you plan to use SSD (and you may need SSD if your system is resource demanding).
- File system discard option. Recommended for SSD to avoid the need to read before write.
- Consider some extra cheaper disks. SSD disks are highly expensive and can have a relatively short life if they are not used properly. Consider placing some cheaper disks (SAS or SATA) to handle tasks that do not require the high end SSD disks.
- Some more recommendations about Linux and SSD from Patrick's:
- File system layer: remove 'relatime' if present and add 'noatime,nodiratime,discard' to reduce writes and improve performance and disk life expectancy.
- Scheduler: use the 'deadline' scheduler instead of 'CFQ' to match SSD behavior.
- Swap: set a small swappiness
- tmp: move /tmp and /var/tmp to RAM disk to improve performance and avoid unneeded writes to disk.
- Partition Alignment: when creating a partition, enter a start sector of at least 2,048 and divisible by 512 to align pages.
- MySQL 5.6. 5.6 if finally in GA and it good idea to start working with it before 5.5 become obsolete.
Bottom Line
Few decisions can enhance your MySQL performance. Make your decisions right.
Keep Performing,
Moshe Kaplan
Feb 27, 2013
Instant Deployment with git
One of the nicest things in git is that you can actually deploy code to production (or just your test environment) w/o implementing a complicated CI solution.
Off course that using CI such as Jenkins is recommended when compilation is required (JAVA/C/C++/C#) or when TDD/unit tests are use (and you better use them).
Yet, when you just need to deploy, git can be a great service for you.
Note: please note that you must an ssh access from the local machine (not always feasble).
How is done?
Actually it is very simple (and a complete explenation can be found at stackoverflow and toroid):
Step #1: Setup a repository in the development environment and commit a first file
> git init
Step #2: Setup an environment at the web server
> mkdir /path/to/dir/website.git && cd /path/to/dir/website.git
> git init --bare
> git add index.html
> git commit -q -m "The index file was commited"
> git push web
Bottom Line
It is a simple task, but tricky if you don't have a direct access to the server (anyone said Jenkins?)
Keep Performing,
Moshe Kaplan
Off course that using CI such as Jenkins is recommended when compilation is required (JAVA/C/C++/C#) or when TDD/unit tests are use (and you better use them).
Yet, when you just need to deploy, git can be a great service for you.
Note: please note that you must an ssh access from the local machine (not always feasble).
How is done?
Actually it is very simple (and a complete explenation can be found at stackoverflow and toroid):
Step #1: Setup a repository in the development environment and commit a first file
> git init
Step #2: Setup an environment at the web server
> mkdir /path/to/dir/website.git && cd /path/to/dir/website.git
> git init --bare
Step #3: Enable a post receive hook at the web server
> mkdir /var/www/www.mydomain.com
> cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/www.mydomain.com git checkout -f
> chmod +x hooks/post-receive
Step #4: Create a trigger at the development environment (and why you need ssh access from the workstation).
> git remote add web ssh://www.mydomain.com/path/to/dir/website.git
> git push web +master:refs/heads/master
Step #5: Code, Commit and Push to production
> echo 'Rocking website!' > index.html> git add index.html
> git commit -q -m "The index file was commited"
> git push web
Bottom Line
It is a simple task, but tricky if you don't have a direct access to the server (anyone said Jenkins?)
Keep Performing,
Moshe Kaplan
Feb 13, 2013
Tracing SQL Server Performance and Stability Issues
The following two undocumented stored procedures will do a miracle to your efforts to trace issues in SQL Server:
The first can be used to find failures, backup procedures and other goodies in the database log. The second can be used to trace heavy UPDATE, DELETE and INSERT transactions in the transaction log of a specific database.
Keep Performing,
Feb 11, 2013
mongoDB Configuration File Tuning
For those of us who are regular to MySQL, its configuration file (my.cnf) and the many options in it (some may say too many), mongoDB seems to be the simple.
With only few dozens of parameters in the configuration file (mongo.conf) and a dozen that are actually related to performance tuning, it may be a relatively short task to tune a mongoDB configuration file. Probably some of us will pay for that in production...
NOTE: this post does not refer the Sharding configuration.
What Can be Done?
Number of Connections
Like many other products (Apache httpd, MySQL...) the number of user connections can affect performance. mongoDB supports that using maxConns = N. Numbers can reach 20,000, but you should adjust it to your own server resources.
Write to Disk
Disk writing is usually a bottleneck in database systems. Therefore, wrtie to disk frequency and initial storage allocation can highly efhttp://stackoverflow.com/questions/8331099/what-is-the-javascript-engine-that-runs-mongodb-shellfect your system performance. Yet notice that delaying disk writing can effect your system recovery (many of you probably familiar with it from MySQL).
You should notice the following two options:
mongoDB provides many supporting services. Disabling some of them (if you do not use them), may help you save some CPU cycles:
With only few dozens of parameters in the configuration file (mongo.conf) and a dozen that are actually related to performance tuning, it may be a relatively short task to tune a mongoDB configuration file. Probably some of us will pay for that in production...
NOTE: this post does not refer the Sharding configuration.
What Can be Done?
Number of Connections
Like many other products (Apache httpd, MySQL...) the number of user connections can affect performance. mongoDB supports that using maxConns = N. Numbers can reach 20,000, but you should adjust it to your own server resources.
Write to Disk
Disk writing is usually a bottleneck in database systems. Therefore, wrtie to disk frequency and initial storage allocation can highly efhttp://stackoverflow.com/questions/8331099/what-is-the-javascript-engine-that-runs-mongodb-shellfect your system performance. Yet notice that delaying disk writing can effect your system recovery (many of you probably familiar with it from MySQL).
You should notice the following two options:
- Delay journal (database log) write to disk using journalCommitInterval = 300. This parameter supports intervals between 2ms (slowest but safest for recovery) and 300ms (fastest but prone to recovery options). The default os 100ms, but you may increase it to 300ms to save resources.
- Preallicate space at mongoDB startup by keeping noprealloc = false.
mongoDB provides many supporting services. Disabling some of them (if you do not use them), may help you save some CPU cycles:
- BSON validation using objcheck = false.
- HTTP Interface using nohttpinterface = true. The mongoDB HTTP interface exposes the database statistics and enables simple REST queries through port 28017.
- Scripting Engine using noscripting = true. mongoDB is using SpiderMonkey JavaScript scripting engine to enable interactive shell. Somehow, I have a feeling that you are not going to disable it.
- REST service using rest = false. See in the HTTP interface.
- Profiling service (inc. slow queries logging) using profile = 0.
Bottom Line
mongoDB is a simple, yet very effective tool to solve many business needs. Doing some tuning will help you avoid issues during peak times.
Keep Performing,
Labels:
mongo.conf,
mongoDB,
mongoDB tuning,
my.cnf,
Performance Tuning
Subscribe to:
Posts (Atom)