Three-tier mobile apps stress testing: Part I – Prepare your environment

Three-tier mobile apps stress testing: Part I – Prepare your environment

When developing user service systems based on three-tier architecture one must take care about server load depending on number of users and user actions in the system. In a few tutorials we are going to describe an approach how to make a good test of your system including server and mobile app.


First, and often most important, step is to create good model of your system before you start coding the system. It is important to think about system requirements, number of users and user actions. Get familiar about the environment where your system will be running, limitations on technologies you are about to use etc. So preparation is the key of developing robust and high-performance three-tier architecture systems.

After you have developed your system first you should do initial testing of your services. If that testing show some errors you should fix those before you start with preparation for stress testing.

When your services are ready to use you can start to preparing stress test environment for your system. First, you should think about how much user and user action is your system is projected to carry on. If that is done, now you have to fill your database with some dummy data in order to do the testing. For this test you should fill db with 50-75% more data than you expect your system will have. In that way you will avoid your system to collapse on peak. If you expect to have bigger peak you will need to put more data.

Get familiar about the environment where your system will be running, limitations on technologies you are about to use etc.

Fill your DB

In order to fill your base you will need to develop small AI system which will insert some dummy data into it. Since you have already developed and tested your services you can use them to fill your base. First you should insert some dummy users. For that you should use your Sing Up (add new user) service. The best way would be is to create simple PHP script which will have simple random string (also number, timestamp or any other formatted data you need) generator function. Also you should temporarily adjust your services to work with plain passwords so that you can automate all process.

Here is simple php random string generator function:

function randString($length, $charset='ABC DE FGHIJ KLMNOP QRS TUVW XYZabcd efghijkl mnop qrstuvwxyz 012345 6789')
{
	$str = '';
	$count = strlen($charset);
	while ($length--) {
		$str .= $charset[mt_rand(0, $count-1)];
	}
	return $str;
}

After you have inserted users you should add dummy user actions. For this action is also recommended to use your services, ones that your mobile app will use to communicate with server. In this way you will test how much your setter services loads your system. More about measuring system load further in text under Load Measure. In order to do this it is very important to create workflow of actions that must be done in order to fill data. Here you are going to simulate mobile app user.

For example:
– Select one user from DB
– Log that user in using login service
– Do action 1
– Do action 2 which depends on results of action 1 (or requires action 1 to be done first)
– …
– Log out user

Most important thing is to create workflow which will respect the logic of the system, so that test could emulate mobile app. For this you can also create simple PHP script and use same random generator functions as before. It is also recommended to add this data in blocks. If you have, lets say, 100 000 users you should to add user action for 5 000 users at the same time. This is because your system will probably will not be able to handle so manny inserts at once. Good thing would be to create cron job which will call the script automatically and select next 5 000 users every hour (half an hour). These numbers depends on your running environment.

After you have entered all data you can start testing your services load on system.

Most important thing is to create workflow which will respect the logic of the system.

Load Measure

In order to test single service load you will need to measure some data to see how good is your system. Data you should need to take in consideration are: memory usage, cpu usage and time of execution. In order to do this you can create simple PHP script which will call services with some random data. At the end of the script you can then echo data you want. If you are using PHP in your system then you should need to measure how much memory Zend actually alloc for your script, because it allocate more memory than your script need. In order to efficiently measure CPU you will need SSH access to your server or your system admin will need to provide that data. Be aware that overall exec time on mobile app will be greater due to generating UX and filling it with data.

Overall exec time on mobile app will be greater due to generating UX and filling it with data.

Optimize

After you have measured all data you needed now you know which services are critical. Before real stress testing you will need to optimize every service whose data are exceeding expected values. In order to do this you might need to rewrite your queries and divide job between system and DBMS to achieve optimal load. You will never be able to have ideal load but you should try to low it down to make your services usable.

That is why you must first get familiar about the environment where your system will be running, limitations on technologies you are about to use.

Ivan Lovrić

Ivan Lovrić

Explore more
articles

We shape our core capabilities around lean product teams capable of delivering immense value to organisations worldwide

Got a project?
Let's have a chat!

Zagreb Office

Radnička cesta 39

Split Office

Put Orišca 11, 2nd floor

Contact info

Split+Zagreb, Croatia
+385 91 395 9711info@profico.hr

This website uses cookies in order to provide a better user experience and functionality. By continuing to browse the site you agree to our  Cookie and Privacy Policy .