good advice for speed your website

Yesterday a friend was requesting a MYSQL/PHP Consultant to speed up his websites, and today I was reading few comments and solutions on his facebook : Use APC, mem_cache for PHP, mysql query caching, use nginx instead of Apache, Use mysqli extension instead of adodb or mysql extension ... etc. Of course all of these could be solutions, but unless you have previously located what the problem really is.

A website could be slow for many reasons, and to be able to fix it and make it run faster you have to first find problem. What you will need to know is :

1- Understand the business :

Before looking into PHP or MySQL, have a first look at the website(s) and answer these two questions :

- What is slow
- Why is it slow

Look at the page size, images, video, flash, ... your issue might be in the client side and everything else might be good.
Use a tool like Firefox web developer extension and disable everything : CSS, Javascript, Images... and load the page as html to feel the difference.
The business here is NOT the business logic behind the website, it's the interface that people use to interact with the website. If everything looks okay, you can go for further server-side investigations.

2- Understand the production environment : Operating system, PHP and MySQL versions, PHP extensions running, PHP and MySQL configurations.

Do not start optimizing code or database unless you know the exact problem, otherwise you have to start by understanding and optimizing the working environment. Some tweaks in PHP and MySQL settings might fix your problem and you won't probably need to dig deeply into any code.

3- Understand the code :

If the websites you are looking to optimize are using a common framework or CMS, let's say Drupal, Wordpress, Zend Framework, Symfony... such websites you can deal with separetely since most optimization issues should be known and you will easily find your way to speed things up.

Otherwise, for custom code and custom application development, start with debugging and focus firstly on the database. That's where most slow issues come from, especially if the concerned website was running fast in the beginning then become slow over the time due to database size going bigger, query & index issues...

4- Debug : detect and locate bottlenecks

Debuggers are your friends here, whatever the environment you are running. Answer again previous questions (What and Why) but this time with relation to the code itself.

You might consider running a stress test here to simulate real working environment. Such tests could help you understand more networking issues and make it easier to locate slowliness based on real scenarios. Test should also simulate real environment, and you will need to save speed result for comparison later.

5- Solution proposal and action plan

Now you can go ahead and set possible solutions : fixing bugs, caching code/queries, tweak your settings... Make sure your modifications will not affect other working website in the same environment - if any is somehow related or linked.

Finally you can run previous stress test with new configuration and updates to see the difference in speed gained. A report of previously mentioned steps should be written including result.

Article originally posted on HBY Consultancy

转载于:https://www.cnblogs.com/bluestyle/archive/2010/12/26/1917038.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值