News Feed
Jobs Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Ulf Wendel:
PHP Memcache access to MySQL 5.7, faster? Redis?
December 13, 2013 @ 12:56:50

In a new post to his site Ulf Wendel shows an alternative use for the PHP Memcache functions - using them to query MySQL tables (InnoDB) in much the same way. He also tosses in Redis as another version to compare the performance against (for fetching key/value pairs).

PHP users can use two client protocols to query MySQL 5.6 and later. Not only standard SQL access but also faster key-value access to InnoDB tables is possible using the Memcache protocol. The MySQL benchmark team reports crazy figures. Of course, on hardware that makes the average PHP meetup visitor roll his eyes and say "yeah, Oracle, *yawn*". I've repeated my plain PHP benchmarks on an i3 desktop. And, I've added Redis to the game.

He goes through and compares a few different things with some simple benchmarks around operations per second:

  • MySQL 5.6 Memcache vs. MySQL 5.7 Memcache vs. Memcache vs. SQL
  • MySQL vs. Memcache vs. Redis

For each he's graphed out the results of the benchmarking with some surprising results for those that may thing MySQL isn't as suited as Redis for something like this.

0 comments voice your opinion now!
mysql redis innodb memcache benchmark key value

Link: http://blog.ulf-wendel.de/2013/using-phps-memcache-interface-to-query-mysql-5-7/

Enrise Blog:
Debugging Your Web Application with TCPDump and Wireshark
December 14, 2012 @ 12:50:15

On the Enrise blog Tim de Pater has posted about a different sort of method for debugging your web applications - using a combination of Wireshark and tcpdump to monitor your application's input and output.

Everything is running great, until suddenly the monitoring is yelling, the load on several servers is rising, MySQL queries/second and the memcached commands/second going through the roof, Apache processes are higher than usual, and the website starts giving timeouts. Yes, that sucks. Of course you'll first check everything that comes up in your mind like logs, diskspace, swap, etc. But then you come to a point that you really have to dive into it to find the cause of this sudden problem. There are several ways of doing this. One way I learned the last time we were in this scenario is using tcpdump and Wireshark.

He gives you a brief "getting started" tutorial helping you get things set up - dumping the packets with tcpdump and sifting through the results with Wireshark. His examples are more specific to watching for memcache traffic, but it can easily be applied to more general kinds of requests. Screenshots are also included so you can be sure you're seeing the right kind of results.

0 comments voice your opinion now!
tcpdump wireshark debugging memcache application


Johannes Schlüter:
MySQL, Memcache, PHP revised
October 02, 2012 @ 09:27:54

Johannes Schlüter has a recent post highlighting an interesting PHP extension that can connect memcache with your MySQL server via PHP, the PECL mysqlnd_memcache extension.

Now this blog entry is tagged a s PHP. Hs is that coming into play? - Well, on the one side we have this fast memcache interface, which allows to access almost arbitrarry data from the database. On the other side we have our PHP mysqlnd plugin interface where we can add special features, like query caching or load balancing, transparently to any PHP application. Why not combine those two things? - Good question. That's what we have done in the PECL mysqlnd_memcache PHP extension.

He includes some sample PHP code showing it in action - two examples: one using the "mysqlnd_memcache_set" method to set a memcache server on the MySQL connection and another showing two queries and how they're handled behind the scenes by this driver plugin.

0 comments voice your opinion now!
mysql mysqlnd memcache driver pecl extension


Johannes Schlüter's Blog:
High Performance PHP Session Storage on Scale
November 18, 2011 @ 10:13:25

In this new post to his blog, Johannes Schlüter looks at a high-performance solution to the usual storing PHP session information via a memcache frontend with a MySQL Cluster backend.

Unfortunately even such a system [using MySQL and InnoDB tables] has limits and unfortunately replication is no good solution here to scale further as we will always need a master for writing the updated session data. By using replication we can take some load from it and we can configure a slave which can be promoted to master to keep session alive if the primary master machine fails but at some point in time we need another solution ... but, happy news, again: One doesn't have to look far as MySQL cluster will be happy to help. MySQL Cluster "is a high-availability, high-redundancy version of MySQL adapted for the distributed computing environment," as the MySQL documentation states.

He describes the setup (after pointing to this post about installing MySQL Cluster for memcache) and includes some sample code/SQL/ini settings you'll need to use to get PHP's memcached functionality to cooperate with it.

0 comments voice your opinion now!
performance session storage mysql cluster memcache frontend backend


Script-Tutorials.com:
How to use Memcache with PHP
September 28, 2011 @ 11:06:47

In a new tutorial from the Script-Tutorials.com site, they introduce you to memcache, an external caching tool that can help speed up the performance of your application dramatically.

Today we will talking about caching in PHP again. I will show you how you can use Memcache in PHP. We will prepare useful class for working with Memcache for us and several examples. Memcache itself providing procedural and object oriented interface to memcached, highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications.

Included in the article is a simple "CacheMemcache" class that handles the dirty work for you of connecting to the memcache instance and pushing/pulling the data from the remote source. Also included are a few examples of its use - storing simple objects, pulling the same data back out and deleting a record. The source for the tutorial can be downloaded here. You can also find out more about using memcache in the PHP manual (Note: it does require an extension to be loaded to support this functionality).

0 comments voice your opinion now!
tutorial memcache caching


PHPBuilder.com:
Build Blazing Fast PHP Websites with Memcached Distributed Caching
July 29, 2011 @ 11:07:53

On PHPBuilder.com today Jason Gilmore has written up a new tutorial about using memcached distributed caching for better performance in your web applications.

You probably know one of the easiest ways to improve performance is by caching all or parts of a page. But what might not be so obvious is exactly how this is accomplished. As it happens, a great solution called Memcached makes it trivial to incorporate caching into your website with great effect. In fact, relied upon by some of the largest websites in the world, among them Facebook, Twitter, Zynga, and YouTube, Memcached has essentially become the de facto website caching solution!

He walks you through installing the memcache extension for PHP (from PECL) and includes a bit of sample code that caches some fetched MySQL results to to the memcache server. With the extension installed you're just a few simple function calls away from better performance.

0 comments voice your opinion now!
memcache memcached performance distributed cache tutorial


Dave Marshall' Blog:
Asynchronous cache priming with progress bars via Gearman, Memcache and Dojo
April 04, 2011 @ 10:18:20

Dave Marshall has written up a new post showing how he's used memcache, Gearman and Dojo to create an asynchronous progress bar he uses when generating large reports.

I have a (highly optimised) report that takes way too long to generate, up to around 30 seconds. [There's] too many variables to prime caches for every possible combination [and] personally, I don't think the browsers inbuilt progress bar is enough feedback for todays web users.

He generates the data into memcache when the user requests it and uses the Gearman worker processes to handle requests for data that doesn't yet exist. The progress bar is a part of Dojo and uses the dijit.ProgressBar widget to keep checking the progress of the build. This way the user can even leave the page and come back if the process takes too long with no threat to the generating report. You can find all of his code he's used to make it happen on his github account.

0 comments voice your opinion now!
gearman tutorial memcache dojo progressbar generate report


Ole Markus' Blog:
High load websites A lock on Memcachedget
December 27, 2010 @ 12:34:14

Ole Markus has a new post to his blog looking at a technique for working with memcached and fetching data out of the store using a binary semaphore for better performance.

A typical document takes but a few hundred milliseconds to generate when a single request for the document enters the backend. The problem is that this is a highload website. In its current form, the backend serves hundreds of pages per second. This pretty much guarantees that the backend will concurrently receive cache miss on multiple languages and at the same time also receive cache miss on the pre-translated document.

Given that he wants the translated version to be the one that's always shared, a problem can come up when the cache request is "missed" and the document starts generating from multiple places. His fix for the situation is that only the first miss generates and all others see a lock on it and wait for it to be removed before successfully fetching the result. He provides code in a "LockedMemcached" class to help make it all more useful.

0 comments voice your opinion now!
lock memcache get set high load website varnish


Simas Toleikis' Blog:
PHP data caching techniques
December 13, 2010 @ 08:45:10

Simas Toleikis has posted some caching techniques he's come up with to handle a few different situations including simple file-level caching and working with memcached.

Caching intermediate data is the most primitive and yet the most rewarding optimization technique where you don't need to fiddle with any complex algorithms or premature optimizations. If you are into PHP you should be aware of all the best practices and the right tools for this job to make your websites fly.

He covers a few different, though common, situations you may come across in your application where caching could be very helpful:

  • Static scope variables
  • APC shared memory functions
  • Memcached for large distributed caches
  • In-memory database tables
  • Simple file-level caches
0 comments voice your opinion now!
caching technique situation apc memcache file memory


Mike Willbanks' Blog:
Zend Framework Cache Backend Libmemcached + Session Cache
October 25, 2010 @ 10:13:11

Mike Willbanks has a new tutorial posted to his blog today about combining memcache and the Zend Framework's caching component to work with session handling.

If I haven't said it before, I suppose I will say it now, I love memcached; it is a wonderful tool to have in your tool belt. However, Zend Framework does not currently have an official cache adapter for Memcached (it has one for the extension memcache but not memcached). [...] About 6-9 months ago, I had implemented a Session_SaveHandler_Cache (although it seems some others have as well), to plug this all in together and keep things consistent in a ZF application. It now enables us to utilize the consistent hashing from the Libmemcached adapter by using the PHP Memcached extension.

He moves on into the details of how to save session information into the memcache with a Zend Framework application, using a Zend_Session_SaveHandler_Cache component (code included) as a light-weight interface between the caching server and the application. He also includes the configuration you'll need to add to your application.ini, additions to the bootstrap and a neat trick using the Subversion revision to prefix the cache entry name (a "versioned" caching system).

0 comments voice your opinion now!
zendframework cache backend memcache session tutorial



Community Events











Don't see your event here?
Let us know!


language opinion install security unittest application package hack code podcast overview hhvm composer release symfony2 introduction facebook example framework component

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework