This tutorial explains some of the things you can do to ensure that your websites hosted on Alibaba Cloud run as quickly and efficiently as possible. It will suggest optimizations that will boost performance, including speeding up site loading time and search queries.
To follow this tutorial, you'll need an Alibaba Cloud account. If you don't already have one, head to www.alibabacloud.com and sign up. To help you try out the facilities you'll find a range of free trials there.
Spend some time browsing your website within the developer tools section of your browser, to discover where any bottlenecks are. Right click and select Inspect to reveal browser tools that will highlight components such as images and scripts which are taking a long time to load.
Select the Network tab to view the loading times of various elements, including images, CSS and Scripts.
You can then work on optimizing and caching them to improve performance.
If you haven't enabled Gzip compression in your web server, try turning it on. Web browsers which understand compression will automatically request compressed pages from the server, which will reduce the amount of data transfer by up to 70%.
To check if your site has Gzip enabled, you can use a site such as http://checkgzipcompression.com/ to find out.
<script src="demo_defer.js" defer></script>
This will speed up the loading of pages and improve the overall user experience.
Check that the image files used on your site are no larger than they need to be.
If your page banner is 600 pixels wide, don't upload a 3,000-pixel wide image to the web server and allow the browser to crop it. This will make the user's browser download all 3,000 pixels in each row, when 2,400 of them will simply be discarded.
Instead, crop your images to the correct size before you upload them to your site.
Use monitoring facilities to check that your server isn't overloading. Services such as CloudMonitor will automate the performance monitoring of all your web resources and applications in real time.
If CPU usage is regularly hitting 80% or more, you should think about upgrading to a more powerful server with more virtual CPUs and more RAM. You could also split your site across multiple servers.
For example, if your web server and database server are on the same instance, you could move the database server to its own instance and configure your web site to fetch its data from the new location. It's easy to do and will increase performance dramatically. Instead of creating a new server instance to host MySQL, look at ApsaraDB for RDS, an Alibaba Cloud service that makes it easy to create scalable database servers with no management overhead.
If your site is particularly busy, you can use the Alibaba Cloud CDN, or Content Delivery Network, to store site assets such as images, PDF and CSS files. This will automatically ensure that users are served files from the server that is physically closest to them, cutting down on latency issues that are usually caused by distribution, bandwidth and server performance issues.
If your site uses a MySQL database, there are some great things you can do to speed up queries, and thus the entire site. Firstly, ensure that you create indexes for all columns used in "where", "order by" and "group by" clauses in your SELECT statements. If you've got phpMyAdmin or adminer installed, this is easily done via the web-based interface.
Use the EXPLAIN command to have MySQL show you how an index can improve things.
Don't use wildcards in queries. Specify the names of the columns you want to return. If you just use an asterisk to specify all columns, MySQL can't use indexes.
MySQL supports different data types including integer, float, tinytext, text, and more. When designing your tables, shorter is always better. For instance, if you are creating a user's table that will hold no more than 100 users, store the user id in a TINYINT column rather than integer because it will accommodate all your possible values.
Finally, wide tables can slow down your database server. So don't have more than 100 columns in any table, unless there really is no way around it.
In this tutorial we've shown you some tips to make your websites and MySQL databases run faster on Alibaba Cloud. Why not try out some or all of them on your own sites?
Alibaba Clouder - November 3, 2017
Alibaba Clouder - July 24, 2018
- December 5, 2017
Alibaba Clouder - August 22, 2018
Alibaba Clouder - June 28, 2017
Alibaba Clouder - December 14, 2017
Automate performance monitoring of all your web resources and applications in real-timeLearn More
A scalable and high-performance content delivery service for accelerated distribution of content to users across the globeLearn More
An on-demand database hosting service for MySQL, SQL Server and PostgreSQL with automated monitoring, backup and disaster recovery capabilitiesLearn More
More Posts by Alibaba Clouder