tailieunhanh - Thiết kế mạng xã hội với PHP - 44

Một trong những yếu tố quan trọng nhất khi nói đến hiệu suất, tốc độ, và khả năng mở rộng của trang web của chúng tôi, là mã của chúng tôi. Bằng cách cải thiện hiệu suất của mã của chúng tôi, nó tiêu thụ ít tài nguyên hơn, cho phép chúng tôi để có được nhiều hơn từ các phần cứng hiện tại của chúng tôi. | Planning for Growth Code performance One of the most important factors when it comes to the speed performance and scalability of our site is our code. By improving the performance of our code it consumes fewer resources allowing us to get more out of our current hardware. Thankfully because we have used the Model-View-Controller architecture our code is already maintainable extendable and flexible which is a big advantage particularly with regards to plugging in new features further down the line. So what can we do to improve our code performance We can profile our code to look for problems We can look for slow MySQL queries that we can optimize We can compress our output Code profiling We can profile our code to find bottlenecks in our code so that we know which aspects need improving or refactoring. Profiling tools such as xdebug http are integrated into PHP to run as our scripts run logging performance information to a file which we can analyze using another suitable tool with xdebug we can use tools such as KCacheGrind or WinCacheGrind . Slow queries MySQL can be configured to log slow queries so that we can see which queries are taking too long to run so that we can investigate them improve the queries or improve the database scheme itself that is by adding more suitable indexes. To enable the slow query log we simply add the following line to our MySQL configuration file file log-slow-queries Once enabled the query log by default logs queries that take longer than 10 seconds to complete we can change this by adding the following line to our configuration file set-variable long_query_time 2 412 Download from Wow eBook Chapter 14 Compression By compressing our website s output we can reduce network latency between the server and the user and reduce bandwidth usage making the site load faster. While the code won t be generated any quicker it should be received by the user faster. This can be

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.