Virtual Hadoop

A recurrent question on the user mailing lists is "can Hadoop be deployed in virtual infrastructures", or "can you run Hadoop 'in the Cloud'", where cloud means "separate storage and compute services, public or private".

The answer is "yes, but you need to be aware of the limitations"

Strengths of VM-hosted Hadoop

This sounds appealing, and is exactly what Amazon Elastic MapReduce offers: a version of Hadoop on a Pay-as-you-go-basis.

For more customised deployments, Apache Whirr can be used to bring up VMs, something documented by Cloudera. There have also been demonstrations of alternate systems running on different infrastructures, such as shown in Farming Hadoop in the Cloud.

Does this mean that Hadoop is ideal in Cloud infrastructures? No but it can be done.

Hadoop's Assumptions about its infrastructure

Hadoop was written expecting to run in large physical datacenters. Such datacenters and physical hardware, storage and networking has some specific features.

  1. A large cluster of physical servers, which may reboot, but generally recover, with all their local on-server HDD storage.
  2. Non-RAIDed Hard disks in the servers. This is the lowest cost per Terabyte of any storage. It has good (local) bandwidth when retrieving sequential data: once the disks start seeking for the next blocks, performance suffers badly.
  3. Dedicated CPUs; the CPU types are known and clusters are (usually) built from homogeneous hardware.
  4. Servers with monotonically increasing clocks, roughly synchronised via an NTP server. That is: time goes forward, on all servers simultaneously.
  5. Dedicated network with exclusive use of a high-performance switch, fast 1-10 Gb/s server Ethernet and faster 10 + Gb/s "backplane" interconnect between racks.
  6. A static network topology: servers do not move around.
  7. Exclusive use of the network by trusted users.
  8. High performance infrastructure services aid Hadoop (DNS, reverse DNS, NFS storage for NameNode snapshots)

  9. The primary failure modes of machines are HDD failures, re-occurring memory failures, or overheating damage caused by fan failures.
  10. Machine failures are normally independent, with the exception of the failure of Top of Rack switches, which can take a whole rack offline. Router/Switch misconfigurations can have a similar effect.
  11. If the entire datacenter restarts, almost all the machines will come back up -along with their data.

Hadoop's implementation details

This translates into code features.

  1. HDFS uses local disks for storage, replicating data across machines.
  2. The MR engine scheduler that assumes that the Hadoop work has exclusive use of the server and tries to keep the disks and CPU as busy as possible.
  3. Leases and timeouts are based on local clocks, not complex distributed system clocks such as Lamport Clocks. That is in the Hadoop layer, and in the entire network stack -TCP also uses local clocks.
  4. Topology scripts can be written to describe the network topology; these are used to place data and work.
  5. Data can be transmitted between machines unencrypted.
  6. Code running on machines in the cluster (including user-supplied MR jobs), can be assumed to not be deliberately malicious.
  7. Missing hard disks are usually missing because they have failed, so the data stored on them should be replicated and the disk left alone.
  8. Servers that are consistently slow to complete jobs should be blacklisted: no new work should be sent to them.
  9. The JobTracker should try and keep the cluster as busy as possible, to maximise ROI on the servers and datacenter.

  10. When a JobTracker has no work to perform, the servers are left idle.

  11. If the entire datacenter restarts, the filesystem can recover, provided you have set up the NameNode and Secondary NameNode properly.

How a virtual infrastructure differs from a physical datacenter

Hadoop's assumptions about a datacenter do not hold in a virtualized environment.

  1. Storage is usually one or more of transient virtual drives, transient local physical drives, persistent local virtual drives, or remote SAN-mounted block stores or file systems.
  2. Storage in virtual hard drives may cause a lot of seeking, even if it appears to be sequential access to the VM.
  3. Networking may be slower and throttled by the infrastructure provider.
  4. Virtual Machines are requested on demand from the infrastructure -the machines will be allocated anywhere in the infrastructure, possibly on servers running other VMs at the same time.
  5. The other VMs may be heavy CPU and network users, which can cause the Hadoop jobs to suffer. Alternatively, the heavy CPU and network load of Hadoop can cause problems for the other users of the server.
  6. VMs can be suspended and restarted without OS notification, this can cause clocks to move forward in jumps of many seconds.
  7. Other users on the network may be able to listen to traffic, to disrupt it, and to access ports that are not authenticating all access.
  8. Some infrastructures may move VMs around; this can actually move clocks backwards when the new physical host's clock is behind that of the original host.
  9. Replication to (transient) hard drives is no longer a reliable way to persist data.
  10. The network topology is not visible to the Hadoop cluster, though latency and bandwidth tests may be used to infer "closeness", to build a de-facto topology.
  11. The correct way to deal with a VM that is showing re-occuring failures is to release the VM and ask for a new one, instead of blacklisting it.
  12. The JobTracker may want to request extra VMs when there is extra demand.

  13. The JobTracker may want to release VMs when there is idle time.

  14. A failure of the hosting infrastructure can lose all machines simultaneously.

Implications

Ignoring low-level networking/clock issues, what does this mean?

  1. When you request a VM, it's performance may vary from previous requests. This can be due to CPU differences, or the other workloads.
  2. There is no point writing topology scripts.
  3. All network ports must be closed by way of firewall and routing information, apart from those ports critical for Hadoop -which must then run with security on.
  4. All data you wish to keep must be kept on permanent storage: mounted block stores, remote filesystems or external databases. This goes for both input and output.
  5. People or programs need to track machine failures and react to them by releasing those machines and requesting new ones.
  6. If the cluster is idle. some machines can be decomissioned.
  7. If the cluster is overloaded, some temporary TaskTracker only servers can be brought up for short periods of time, and killed when no longer needed.

  8. If the cluster needs to be expanded for a longer duration, worker nodes acting as both a DataNode and TaskTracker can be brought up.

  9. If the entire cluster goes down or restarts, all transient hard disks will be lost, and all data stored within the HDFS cluster with it.

The most significant implication is in storage. A core architectural design of both Google's GFS and Hadoop's GFS is that three-way replication onto local storage is a low-cost yet reliable way of storing Petabytes of data.

In a cloud infrastructure, this design is no longer valid. If you assume that it does, you will be disappointed when one day all your data disappears. Please do not complain if this happens after reading this page: you have been warned.

Why use Hadoop on Cloud Infrastructures then?

Having just explained why HDFS does not protect your data when hosted in a cloud infrastructure, is there any reason to consider it? Yes.

You just need to recognise the limitations and accept them:

Hosting on local VMs

As well as large-scale cloud infrastructures, there is another deployment pattern: local VMs on desktop systems or other development machines. This is a good tactic if your physical machines run windows and you need to bring up a Linux system running Hadoop, and/or you want to simulate the complexity of a small Hadoop cluster.

Summary

You can bring up Hadoop in cloud infrastructures, and sometimes it makes sense, for development and production. For production use, be aware that the differences between physical and virtual infrastructures can threaten your data integrity and security - and you must plan for that.

Virtual Hadoop (last edited 2011-10-05 20:56:36 by SteveLoughran)