budtmo / docker-android

Android in docker solution with noVNC supported and video recording
Other
9.93k stars 1.3k forks source link

docker-android under VM has slow performance #17

Closed alanbuenoerlabs closed 6 years ago

alanbuenoerlabs commented 7 years ago

Hey Budi,

I don't know if it's because of the noVnc interface or something like that, but the devices on the server got too slow, slow for any kind of task, have you handle this situation too? I'm mounting the devices on a clean ubuntu server through docker-compose up -d and a simple yml file based on the example you gave. Machine resources were not the problem, I put some more memory and cpu but still without success.

  1. The initialization of the device isn't the problem, it's getting ready in 4-6 minutes, or less. The delay is on the interaction with the device, I send commands from a remote app with the selenium instructions or I move the screen with the mouse on the interactive window of noVnc and the device take about 1-2 seconds to respond.

  2. It's a VMware station with a lot of virtualized servers, this ubuntu I'm using is one of the many there and have only docker and docker-compose installed.

  3. Intel(R) Xeon(R) CPU E5-2640 0 @ 2.50GHz, 8 cores, 8G Memory and a little bit of hard disk.

  4. I used the butomo1989/docker-android-x86-6.0 with the Nexus 5 and Samsung Galaxy S6. deviceimage

  5. I already started a Grid individually and then used a command like this that you gave as example: docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" -e APPIUM=True -e CONNECT_TO_GRID=True -e SELENIUM_HOST="172.17.0.X" -e SELENIUM_PORT=4444 -e MOBILE_WEB_TEST=True --name android-container butomo1989/docker-android-x86-6.0

But it was not the solution. :(

  1. I didn't change the scale of the yml file, but I'm thinking the problem isn't the resources, because, looking in the active containers, it didn't scaled up to another container and still have a lot of resources available.

I made the device more soft and fast downloading inside the device container the Intel x86 Atom System Image and adjusting the config.ini file in the .android directory of the device to point to this new image. Than I could play with the device more fluidly and faster, but still couldn't get the speed of the local emulations.

Device new image: newdeviceimage

Inicial docker-compose.yml (image because Markdown was messing the commands): docker-compose

How would you tune up the performance of the emulation?

Best regards,

Alan Bueno

budtmo commented 7 years ago

Hi @alanbueno ,

Thank you for reporting this issue. as I understand that you are using VMWare to simulate linux OS, could you provide me guideline or step how you enable hardware virtualisation in that VM to be able to use x86 image (of course you can create PR for it)? because as far as I remember VM do not support hardware virtualisation (see #11 ).

In my linux computer 1 docker-container of docker-android consume 1 GB RAM, but the usage of RAM will get bigger when you start play with it and also depends on your application. e.g. hello world android application in emulator should consume less memory than any other bigger application like google map. Could you run top in your command line in your linux machine and see how many memory do you need for docker-android and how many free memory do you have? and is there any other parallel process running in that VMWare?

alanbuenoerlabs commented 7 years ago

Hi @butomo1989,

I realized that it was not so clear in the issue, but it's a VM running on a physical machine with VMWare ESXI 5.5, Hardware acceleration enabled on bios and Nested Virtualization provided. It can be easily verified with a ubuntu packet called cpu-checker that u can install with:

apt-get install cpu-checker

Once it's installed, we can check the Kvm status with the command:

kvm-ok

It would tell us if this environment is ready to virtualization with hardware acceleration, like shown below: kvmok

There's no any parallel process running, this ubuntu is exclusively for this device virtualization and the numbers with two devices with and without stress.

Without stress: memory2devices

With stress (intense interaction with Google Maps): deviceusagemapsinteraction

Usage: devicesmaps

fernandoravagnani-luizalabs commented 7 years ago

@butomo1989 here was the steps to enable the virtualization in the VM:

screenshot from 2017-06-28 14-48-39

screenshot from 2017-06-28 14-47-19

ps: using hardware or software CPU and MMU was praticaly the same performance

screenshot from 2017-06-28 15-14-06

budtmo commented 7 years ago

Hi,

@alanbueno Honestly I never try to run x86 docker-android image under VM. I just created gitter and could you join there: https://gitter.im/butomo1989/docker-android ? I might need additional informations so I can help you.

@fernandoravagnani-luizalabs Cool! Last time I tried with VM from virtualbox that was created by docker-machine and it didn't work. I will try again to create VM by myself. but I am really glad that it works with other VM like ESXi although there is performance issue. Thank you for the guideline!

budtmo commented 7 years ago

@fernandoravagnani-luizalabs It would be great if you can put that information somehow in README.md and create PR.

budtmo commented 7 years ago

I tried following cases: Host OS: OSX; Virtualbox: Ubuntu 16.04; Status: failed (x86 cannot be run under that VM) Host OS: Ubuntu 16:04; Virtualbox: Ubuntu 16.04; Status: failed (x86 cannot be run under that VM)

It seems Virtualbox has issue with nested virtualisation.

and the solution is by using VMWare.

andrcuns commented 7 years ago

What about Vagrant? Then the setup could be automated as well (don't have experience with it though).

budtmo commented 7 years ago

I will try to run under VMWare player and will provide the docs in the end. Regarding vagrant I might just create ticket and mark as "help wanted". Maybe someone who has experience with vagrant can investigate it. @andrcuns