Pergunta

There are lots of questions on SO asking about the pros and cons of virtualization for both development and testing.

My question is subtly different - in a world in which virtualization is commonplace, what are the things a programmer should consider when it comes to writing software that may be deployed into a virtualized environment? Some of my initial thoughts are:

  1. Detecting if another instance of your application is running
  2. Communicating with hardware (physical/virtual)
  3. Resource throttling (app written for multi-core CPU running on single-CPU VM)

Anything else?

Foi útil?

Solução

You have most of the basics covered with the three broad points. Watch out for:

  • Hardware communication related issues. Disk access speeds are vastly different (and may have unusually high extremes - imagine a VM that is shut down for 3 days in the middle of a disk write....). Network access may interrupt with unusual responses
  • Fancy pointer arithmetic. Try to avoid it
  • Heavy reliance on unusually uncommon low level/assembly instructions
  • Reliance on machine clocks. Remember that any calls you're making to the clock, and time intervals, may regularly return unusual values when running on a VM
  • Single CPU apps may find themselves running on multiple CPU machines, that do funky things like Work Stealing
  • Corner cases and unusual failure modes are much more common. You might not have to worry as much that the network card will disappear in the middle of your communication on a real machine, as you would on a virtual one
  • Manual management of resources (memory, disk, etc...). The more automated the work, the better the virtual environment is likely to be at handling it. For example, you might be better off using a memory-managed type of language/environment, instead of writing an application in C.

Outras dicas

In my experience there are really only a couple of things you have to care about:

  • Your application should not fail because of CPU time shortage (i.e. using timeouts too tight)

  • Don't use low-priority always-running processes to perform tasks on the background

  • The clock may run unevenly

  • Don't truss what the OS says about system load

Almost any other issue should not be handled by the application but by the virtualizer, the host OS or your preferred sys-admin :-)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top