środa, 25 marca 2015

Adventure with Raspberry Pi

Recently I've got very interesting task from guys from devmeetings.pl. They write to me something like this:

There is always a problem with the Internet on live workshops (30 participants, WIFI is not able to handle the traffic, the learning platform make a lot of a request per second). We want to eliminate it: provide a working simple server on Raspberry Pi, which will be physically in the place where the training takes place…. So we want to check if we can run our learning platform on Raspberry Pi and if this little computer can handle this traffic…

And after few days I received a very nice package. The package looks something like this on the left.

Yes it is nice brand new Raspberry Pi 2 (http://www.raspberrypi.org). It was mine first contact with this kind of single-board computer, but when guys from devmeetings asks me to do a few tasks on this platform for them I have got only one answer YES :-) 

This could be a nice challenge or horror :-)… will see.

So I download New Out Of the Box Software (NOOBS) (http://www.raspberrypi.org/downloads/) to install OS for Raspberry PI and extracted it on SD card. After this I connect Pi to my TV to handle OS install…..




OS was installed without any problems and after some time I could connect through SSH to Pi from my laptop.

Now it was time to install node.js. Because of ARM-architecture on Raspberry I need to download node.js version for this specific architecture. 


So I run this commands

and after this I was able to run node –v and npm –v, so far so good :-)



Now I need to run MongoDb on the Pi and with help from https://emersonveenstra.net/mongodb-raspberry-pi/ task was done.:-)



There is only available version 2.1.1 of Mongo for ARM devices, but it should be enough for more cases. Next step was to restore 1.5 GB Mongo DB. With some problems because of lack of space on SD card,  I successfully restored MongoDB .

The learning platform successfully starts! :-)

Because I need to make some load tests I want to monitor performance & health of raspberry itself, so I install great RPI-Monitor (https://github.com/XavierBerger/RPi-Monitor), where gathered information are presented in nice HTML5 pages.

Before I start real test I go to the platform running on PI and I start using it, I clear cache in my browser and start switching between pages and stop on page with editor with live preview(every change in editor was sent to the server and was saved in mongo db, so there ware really a lot of request going on).

During this simple test I haven't noticed any problems with platform performance, and using Chrome Devtools I make some charts presenting network traffic



Latency - empty cache
Switching between pages
Editing large HTML document in editor with live preview
Request was very fast, and the preview of text inserted into editor was updating vary fast.
After using platform for some time I switched on RPI-Monitor to see how PI was doing. And I must say PI was doing very good :-), take a look …

CPU performance during test by one users
Memory used during test by one user
The next step was to simulate 30 users working at the same time on editor. To made it possible I wrote this script which I put on platform. Script simulate writing in the editor.


Because I want to open 30 tabs on my Chrome browser and start test on the every tab at the same time I enable to run script by changing value on LocalStorage



I have to admit that the PI passed the test with very good score :-).

Network traffic - during simulating 30 users

CPU - during simulating 30 users

Temperature - during simulating 30 users

Memory - during simulating 30 users

During test when script writes in the editor, network traffic looks similar on each tab. At the begging the request was block because of  heavy browser load


Summary

It really looks like this small computer ROCKS !!! :-) I made tests on development version of platform and on production version everything should be faster. Raspberry PI was not yet used on live workshops, but I hope it will be. And I want to thanks guys from devmeetings for giving me this opportunity to play with RaspberryPI.