Tag: Performance

Php / MySQL Performance Tuning

Learn to Play Bridge – Wanttoplaybridge.com
Learn Bridge Simply And Quickly – We Offer A Simple To Follow Beginners EBook(R), A Weekly EZine Plus Tips & Puzzles.
Learn to Play Bridge – Wanttoplaybridge.com

Article by Steve Exley

Linux, Apache, PHP and MySQL has fast become the defacto standard in small to medium website development. Ease of use, low start up costs wide availablity of support are all reasons for it’s adoption. Almost all Linux distributions come ready to run LAMP based websites with minimum effort out of the box. However these out of the box approaches are designed to deliver working systems regardless of the hardware underneath. These include ancient processors, low memory systems and rely heavily on resouces like the hard disk to guarantee they work.

With a few easy tweaks, it is possible to turbo-boost the PHP and MySQL components of your web server often generating page delivery increases up to 20% and reducing that all important disk load on your server. Whether you run one disk or more, failing hard disks still cause downtime in all but high end systems. If you are on one disk – then I strongly recommend asking your hosting provider about RAID upgrades. Having 2 or more disks not only provides security in the event of disk failure, but can also be another source of performance boost, It’s normal to notice a 50% increase in speed reading from disks in servers running RAID compared to single disk systems.

Look at PHP first. Every time a page requests a PHP file, your server will read the file from disk, compile the code and run it. Those first two steps are wasteful, wouldn’t it be easier to read the disk and store the compiled code. Then the server would only need to run it for each page request. Most people know that RAM, the memory on your server is faster than the memory on the hard disk, so why not use the RAM! This is exactly how PHP accelerators work. The compiled code can be stored in RAM and used instead of the uncompiled PHP code residing on your hard disk.

There are a number of free PHP accelerators available. APC, eAccelerator and xCache are a few. Zend also produce a paid up version for the over cautious types. I’m not going to discuss the merits/drawbacks of them each, there are other articles that do that. Try a search for ‘PHP accelerator comparison’ and you should see good results. The amount of RAM used by these tools is small, less than 32Mb on servers with only a few sites. More is required on servers with many websites and this is where a configurable accelerator which lets yous specify which files to cache can be useful. Choose the most common / largest PHP files and cache those.

It’s worth noting the Linux systems will use any free memory available to store files too. This works by copying commonly used files unused memory and checking that before reading from the hard disk. It all happens behind the scenes and transparently to the user. Use the command ‘free -m’ in Linux to see what is going on. If you’re using you’re ‘Swap:’ then you need to reduce the services running on your server or ask your hosting provide for a RAM upgrade.

MySQL comes with built in acceleration features. By default these are all tuned right down so MySQL uses the minimum amount of RAM, however if ‘free -m’ on the Linux command line shows you have free ‘Mem:’ then some setting changes will offer big performance gains. Before starting out, check your SQL queries though. An efficient MySQL database structure and well designed queries will offer far better performance gains than just increasing the RAM. Learn how to use Indexes, roughly speaking these should be the fields used to JOIN tables and the fields queried with the WHERE statement.

If you think your queries and databases are hot, but you still want more then you need to tune MySQL itself. I’ll assume that like most people, you have phpMyAdmin installed. If not then you can find how to find this information manually – but you probably won’t be needing to read this article. Go to phpMyAdmin and click the home icon, normal in the top right of the page. Then ‘Show MySQL runtime information’. There is a lot of information here, lets go for the low hanging fruit.

Under ‘Query Cache’, if there are only zeros then your query cache is not even running. Otherwise ‘Qcache_free_memory’ will give you an idea of your current usage. Next is ‘Temporary data’ – what is the ratio of ‘Created_tmp_disk_tables’ to ‘Created_tmp_tables’. You want as many temporary tables as possible to exist in ‘Created_tmp_tables’. Finally check your ‘Key cache’. The ratio of ‘Key_read_requests’ to ‘Key_reads’ should be as high as possible, greater than 100:1 on most systems.

These values all tell you how often MySQL is using RAM compared to the hard disk. Remember, RAM is way faster than the hard disk, so you want to use it as much as possible without affecting other systems. The defaults in MySQL are very low and MySQL needs your permission to use more. This is frequently done using the file ‘/etc/my.cnf’. Some systems may use other locations, but then they would not be using the defaults either. If the file does not exist, then it is safe to create it. You may find some examples in ‘/usr/share/doc/mysql-server-****’. Backup any files before starting. Add the lines ‘key_buffer = 8M’,'query_cache_size=16M’,'tmp_table_size=16M’. Issue a /etc/init.d/mysqld restart and see what happens. The server should be working fine. Monitor it for 24 hours and then look at your values in phpMyAdmin again to see if they show and improvement. Use ‘free -m’ on the Linux command line to ensure you are not using ‘Swap:’ and tweak the values in /etc/my.cnf until you have a good compromise between performance and memory usage. I’ve seen much higher values for all the above on modern systems.

Steve Exley is Technical Manager at studio-40.com and is tasked with the server maintenance of many commercial business websites. Studio-40 is an established created web design agency in Leicestershire, East Midlands.










Learn Any Language Faster
Stop wasting your time and start learning now. Proven tips and tricks make learning any language a natural part of your day. No added study time, no extra effort.
Learn Any Language Faster

Learning PHP / MySQL – Training Course for Mac [Download]

  • Reduce learning time by 80%. Learn from a professional trainer from your own desk.
  • Visual training method, offering users increased retention and accelerated learning.
  • Breaks even the most complex applications down into simplistic steps
  • Ideal for users who prefer to learn visually
  • Easy to follow step-by-step lessons, ideal for all

With Practical Working Files
In this PHP / MySQL video training title from Robert J. Tucker, you will learn the fundamentals of PHP and MySQL. Instead of your standard “this is a variable” type training however, Robert teaches you how to actually apply PHP and MySQL in real world scenarios. This computer software training takes you through building a CRM (customer relationship management) application, and through this teaches you how to leverage the power of PHP and MySQL. You will learn abou

List Price: $ 99.95

Price: [wpramaprice asin="B004RLI320"]

More Learn Mysql Products

Comments Off more...

Improving Mysql Server Database Performance

Crochet Made Easy
Instructional e-book, showing [photographs] and teaching beginners how to crochet. Step by step instructions from how to hold a hook, up to creating your first project. Tips on caring for your crochet, altering the finished size and tension of your item
Crochet Made Easy
MySQL can be a rock solid, lighting quickly database server which has been designed for two factors pace and efficiency. It could be the Ferrari of databases: Light weight, quickly and Built for the higher pace tracks! I nonetheless hear an awful lot of stories from owners whose databases are running two slow. In my experience, the three principal places to seem for issues are:
1. Faulty Database Design
2. Lousy Queries
3. Server factors

Faulty Database Design
Correct database design might be the single most essential factor for the ensuring efficiency and maintainability with the database. Right here is what you have to answer when designing a desk: Can I decrease the size of knowledge that every row will have? Right here is what you are able to do:
1. Use unsigned numeric values when the application is not going to save negative numbers. Like the quantity ordered of an item in an ecommerce application is never going to become -5.

2. Use Variable length values as an alternative to fixed length worth i.e. utilised varchar in place of char.

3. Tend not to use unnecessarily big field sizes. For most ecommerce application unsigned smallint is extra than sufficient to retailer inventory count. A field described as unsigned smallint can keep a max benefit of 65535.

4. Dont ignore normalization; its helps prevent unnecessary repetition of info. The part B of that is, dont overuse normalization. If the desk is not going to grow in size substantially, there’s no point in normalization. For instance, if the user desk has just 20 rows (i.e. 20 employees in a organization), all attempts of normalization are wasted.

5. Use Keys. Dont decide keys by The customer id has to become indexed from the order desk. If the order desk is becoming searched 90% of your times by order date, it makes much more sense to index order date.

Remember, how a desk will probably be employed must determine how it truly is designed. Spending time right here will save years of frustration.

Lousy Queries
It sounds too excellent to become true but you wont believe the number of developers out there who totally suck at writing queries. You will discover two kinds of undesirable queries:
a) Unnecessary Queries: These are the queries that shouldnt have been made inside initial place. The only method to avoid it can be asking, Do I actually need to have this info?
b) Inefficient Queries: These are the queries that usually do not use the underlying desk structure or MySQL functions inside correct way.

Right here is actually a starting point to begin looking at issue areas:
1. Unnecessary utilization of Select * statements when the entire processing is becoming carried out on a single column. The far more info is fetched from the server the extra work MySQL has to do and much more bandwidth it takes.

2. Employing sub-query as an alternative to a join. On a correctly designed database, joins are incredibly rapidly. Making use of sub-queries just shows a lack of knowledge.

3. Improper use of Keys. It can be specially valid for range checks. Remember to use the Explain statement to check the utilization of keys and then use the use crucial statement in your where clauses to force critical utilization.

Server Factors
Every thing carried out correctly, there nonetheless may well be some server factors that may possibly be causing the technique to become slow. These are:
1. Hardware associated

2. Server configuration associated

Right here is what you are able to do about the hardware:
1. The extra RAM is on the method the much better it can be. MySQL often fetches info from the RAM and a lot more the RAM is on the technique, the much better it can be.

2. Purchase the fastest achievable RAM! A slower RAM is just irony.

3. As soon as you will be settled with the RAM size and velocity, seem for processing velocity. MySQL can use multiple processors.

As soon as you might be satisfied with the hardware, you will find a set of variables in my.cnf that you should seem at:
a) key_buffer_size: This describes the memory accessible to save the index keys. The default is 8 MB but you may set it to 25% with the RAM.
b) query_cache_size: This worth is by default ..! if you might have a great deal of repeating queries like in reporting applications and so on, make certain you set this benefit large.
c) table_open_cache: This determines the number of desk descriptors that MySQL will maintain inside cache. The default worth is 64. But, if you’ve 100 users accessing a desk concurrently then this worth require to atleast be 100. You also need to take into considerations joins and so on. Thus, this worth will need to also be kept large.

How To Incorporate Yourself For Free
How to form a corporation without paying a dime in lawyer fees
How To Incorporate Yourself For Free

Creating your MySQL Database: Practical Design Tips and Techniques: A short guide for everyone on how to structure your data and set-up your MySQL database tables efficiently and easily.

If you’re creating a dynamic web application using open-source tools, then you’re probably going to be setting up a MySQL database. Getting the design of this database right for your application and its data is vital, but it’s often an intimidating and little-known process for non-developers and developers alike. Written by the creator of the popular phpMyAdmin tool, this book is a short but complete guide on how to design good data structures for MySQL. Anyone working with applications that use

List Price: $ 19.98

Price:

More How To Mysql Products


SQL Server 2008 Query Performance Tuning Distilled

Earn – per sale with the Forex Trend System!
Earn up to per sale with the Forex Trend System + recurring payments (new!). We provide traders with a simple and easy to use forex trend trading system.
Earn – per sale with the Forex Trend System!

SQL Server 2008 Query Performance Tuning Distilled

SQL Server 2008 Query Performance Tuning Distilled presents a direct trouble–shooting methodology for identifying poorly performing stored procedures and queries, isolating the causes of that poor performance, and fixing the underlying problems. Each chapter is dedicated to one of the top causes of poorly performing queries and shows methods for identifying and dealing with the problems in that chapter’s domain. Emphasis is always put upon or placed upon practical methods that you can put to

List Price: $ 43.99

Price:

Get a New Customer
This is a recurring billing product for the coffee shop industry. It teaches business owners how to drive a flood of new customers into their shops using seven main marketing techniques. Ongoing videos and webinars for members.
Get a New Customer

Inside the SQL Server Query Optimizer

The SQL Server Query Optimizer is perceived by many to be a magic black box, transforming SQL queries into high performance execution plans in the blink of an eye through some unknowable process. The truth is that, while the Query Optimizer is indeed the highly-complex result of decades of research, learning how it works its magic is not only possible, but immensely useful to database developers and administrators alike. A better understanding of what the Query Optimizer does behind the scenes

List Price: $ 29.99

Price:

Related Sql Queries Products


  • Copyright © 1996-2010 sql tutorial for beginners,sql server tutorial,sql tutorial pdf,sql tutorials. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress