Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Mirage - Extreme specialization of cloud appliances (OSCON 2013)

Amir
July 26, 2013

Mirage - Extreme specialization of cloud appliances (OSCON 2013)

Anil and David present the state of Mirage at OSCON 2013 in Porland Oregon

Amir

July 26, 2013
Tweet

More Decks by Amir

Other Decks in Technology

Transcript

  1. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 1/36 Anil

    Madhavapeddy University of Cambridge Richard Mortier University of Nottingham Dave Scott Citrix Systems R&D MIRAGE: EXTREME SPECIALISATION OF CLOUD APPLIANCES @avsm @mort___ @mugofsoup http://openmirage.org http://decks.openmirage.org/oscon13/ http://www.youtube.com/watch?v=2Mx8Bd5JYyo
  2. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 3/36 THE

    CLOUD THREAT MODEL Type-safety in the application layer defeats several external threats. Type-safety in the kernel will make all external I/O safe, but at what cost?
  3. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 4/36 THE

    CLOUD THREAT MODEL Most attacks never come from within a guest, only from external traffic. So why all these privilege checks?
  4. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 5/36 KEY

    DESIGN INSIGHTS The hypervisor gifts us a stable hardware interface. Cures the curse of library operating systems! Protocol-level compatibility between special-purpose cloud appliances, e.g. a webserver, a database VM.
  5. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 7/36 CONTRIBUTIONS

    The unikernel approach to building single-purpose appliances Library OS + high level programming interface Single-address space layout Evaluation of these techniques using a functional programming language (OCaml) Benefits of type-safety need not damage performance Static typing + modules = high level manipulation Language extensions for systems programming in OCaml
  6. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 8/36 CURRENT

    VIRTUAL APPLIANCES Compiler has to stop at userspace. Every level has a different API, calling convention, and privilege requirements.
  7. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 13/36 MICROBENCHMARKS!

    Unikernel appliances are: Smaller, both in kLoC & image size Boot faster, at packet round-trip time timescales High performance Type-safe
  8. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 14/36 APPLIANCE

    IMAGE SIZE Appliance Standard Build Dead Code Elimination DNS 0.449 MB 0.184 MB Web Server 0.674 MB 0.172 MB Openflow learning switch 0.393 MB 0.164 MB Openflow controller 0.392 MB 0.168 MB All configuration and data compiled into the image by the toolchain. Live migration is easy and fun :-)
  9. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 17/36 EVENT

    DRIVEN CO-THREADS Garbage collected heap management is more efficient in a single address-space environment. Thread latency can be reduced by eliminating multiple levels of scheduling.
  10. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 18/36 THREAD

    SCALING SINGLE INSTANCE Threads are heap allocated values, so benefit from the faster garbage collection cycle in the Mirage Xen version, and the scheduler can be overridden by application-specific needs.
  11. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 20/36 TECHNIQUES

    Several implementation techniques give rise to these benefits: Simplified memory management Zero-copy IO buffer management Hypervisor security extension for VM sealing (W^X)
  12. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 21/36 MEMORY

    MANAGEMENT SPECIALISED! Compiled native source code and runtime statically linked with random start offset. IO memory is mapped into a reserved area and can be distinguished. OCaml heap is contiguous, with simpler write barriers as a result.
  13. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 23/36 OPTIONAL

    VM SEALING Single address-space and no dynamic loading W^X address space Address offsets are randomized at compile-time Dropping page table privileges: Added freeze hypercall called just before app starts Subsequent page table updates are rejected by Xen Exception for I/O mappings if they are non-exec and do not modify any existing mappings Very easy in unikernels due to focus on compile-time specialisation instead of run-time complexity
  14. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 24/36 MACROBENCHMARKS

    We have implemented several larger appliances. We discuss deens, our DNS server in detail here. We also have: a simple webserver, an OpenFlow Switch, and an OpenFlow Controller.
  15. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 25/36 DNS

    SERVER CODE let main () = lwt zones = read key "zones" "zone.db" in Net.Manager.bind (fun mgr dev -> let src = `any_addr, 53 in Dns.Server.listen dev src zones ) Cooperative threads as functions Statically evaluated configuration Functional callbacks Libraries directly link to network stack
  16. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 26/36 DNS

    SERVER PERFORMANCE BASELINE Baseline figures, running Bind (standard) and NSD (high performance). NSD achieves around 70 kreqs/s.
  17. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 27/36 DNS

    SERVER PERFORMANCE MIRAGE Comparing against Mirage appliance, with and without simple memoisation. This algorithmic optimisation added just 6 lines of code.
  18. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 28/36 DNS

    SERVER PERFORMANCE C/MINIOS A rudimentary C-based appliance linking NSD directly against MiniOS. Poor user-space library performance vastly outweighs language effects.
  19. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 29/36 SCALING

    VIA PARALLEL INSTANCES Request throughput for serving a simple static page using Apache on Linux vs. a Mirage appliance. Rather than pay the cost of interlocking for thread-level parallelism, we scale by running many instances of the Mirage appliance.
  20. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 30/36 OPENFLOW

    CONTROLLER OpenFlow controller is competitive with NOX (C++), but much higher level. Applications can link directly against the switch to route their data.
  21. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 31/36 SUMMARY

    OCaml is the baseline language for all new code Our C runtime is small, and getting smaller Is fully event-driven and non-preemptive Rewriting protocols wasn’t that hard Not necessarily the best research strategy though But an extremely useful learning experience Tech transfer is vital Unikernels fit perfectly on the cloud Internet protocol building blocks Seamless interop with legacy code through VMs
  22. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 32/36 PURE

    OCAML CODE Device drivers netfront, blkfront xenstore Networking/Communication IP/TCP/UDP/DHCP/DNS(SEC) (v4) HTTP, SSH, OpenFlow (controller/switch) vchan IPC Storage NFS, FAT32 distributed k/v store 9P :-) GITHUB.COM/MIRAGE http://arakoon.org
  23. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 33/36 MIRAGE

    ONLINE Website, Code, O'Reilly OCaml book, OPAM package manager Allows constraints to be applied to package installation Very useful for managing assembly of the many small OCaml modules that construct a Mirage appliance http://www.openmirage.org http://github.com/mirage http://realworldocaml.org http://opam.ocamlpro.com
  24. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 34/36 KEY

    RESEARCH DIRECTIONS Interoperability — with billions of VMs out there A unikernel per-language? Interconnect strategies? Heap sharing? Formal method integration easier or harder? Coordination — planetary scale computers Resources are highly elastic now. How to coordinate a million microkernels? “Warehouse Scale Computing” Library Applications — where are they? Irminsule, a git-like functional distributed database Beanstalk, a self-scaling web server
  25. 7/31/13 Mirage: Extreme Specialisation of Cloud Appliances file://localhost/Users/mort/research/projects/mirage/src/v2/mirage-decks/files/slides/oscon13/complete.html#/ 35/36 WE'RE

    HIRING! MUST ENJOY OPEN SOURCE! OCamlLabs, Cambridge, UK Real world functional programming with OCaml Need compiler hackers, protocol heads, PL/type theory systems Networks-as-a-Service, University of Nottingham, UK (2 posts, 3 years, deadline Friday August 2nd) Joint with University of Cambridge & Imperial College Network virtualisation for millions of microkernel apps Need Mirage hackers, network protocol experts, graph theorists http://www.cl.cam.ac.uk/projects/ocamllabs http://bit.ly/13sBjjC