Unikernel Explained

A unikernel is a computer program statically linked with the operating system code on which it depends. Unikernels are built with a specialized compiler that identifies the operating system services that a program uses and links it with one or more library operating systems that provide them. Such a program requires no separate operating system and can run instead as the guest of a hypervisor.[1]

The unikernel architecture builds on concepts developed by Exokernel and Nemesis in the late 1990s.

Design

In a library operating system, protection boundaries are pushed to the lowest hardware layers, resulting in:

  1. a set of libraries that implement mechanisms such as those needed to drive hardware or talk network protocols;
  2. a set of policies that enforce access control and isolation in the application layer.

The library OS architecture has several advantages and disadvantages compared with conventional OS designs. One of the advantages is that since there is only a single address space, there is no need for repeated privilege transitions to move data between user space and kernel space. Therefore, a library OS can provide improved performance by allowing direct access to hardware without having to transition between user mode and kernel mode (on a traditional kernel this transition consists of a single TRAP instruction[2] and is not the same as a context switch[3]). Performance gains may be realised by elimination of the need to copy data between user space and kernel space, although this is also possible with Zero-copy device drivers in traditional operating systems.

A disadvantage is that because there is no separation, trying to run multiple applications side by side in a library OS, but with strong resource isolation, can become complex.[4] In addition, device drivers are required for the specific hardware the library OS runs on. Since hardware is rapidly changing this creates the burden of regularly rewriting drivers to remain up to date.

OS virtualization can overcome some of these drawbacks on commodity hardware. A modern hypervisor provides virtual machines with CPU time and strongly isolated virtual devices. A library OS running as a virtual machine only needs to implement drivers for these stable virtual hardware devices and can depend on the hypervisor to drive the real physical hardware. However, protocol libraries are still needed to replace the services of a traditional operating system. Creating these protocol libraries is where the bulk of the work lies when implementing a modern library OS. Additionally, reliance on a hypervisor may reintroduce performance overheads when switching between the unikernel and hypervisor, and when passing data to and from hypervisor virtual devices.

By reducing the amount of code deployed, unikernels necessarily reduce the likely attack surface and therefore have improved security properties.[5] [6]

An example unikernel-based messaging client has around 4% the size of the equivalent code bases using Linux.[7]

Due to the nature of their construction, it is possible to perform whole-system optimisation across device drivers and application logic, thus improving on the specialisation.[8] [9] [10] For example, off-the-shelf applications such as nginx, SQLite, and Redis running over a unikernel have shown a 1.7x-2.7x performance improvement.[11]

Unikernels have been regularly shown to boot extremely quickly, in time to respond to incoming requests before the requests time-out.[12] [13] [14]

Unikernels lend themselves to creating systems that follow the service-oriented or microservices software architectures.

The high degree of specialisation means that unikernels are unsuitable for the kind of general purpose, multi-user computing that traditional operating systems are used for. Adding additional functionality or altering a compiled unikernel is generally not possible and instead the approach is to compile and deploy a new unikernel with the desired changes.

See also

External links

Notes and References

  1. Web site: Unikernels: Rise of the Virtual Library Operating System. 31 August 2015.
  2. Book: Tanenbaum, Andrew S.. Andrew S. Tanenbaum . Modern Operating Systems . limited. 3rd . 2008 . Prentice Hall . 978-0-13-600663-3 . 50–51 . . . . nearly all system calls [are] invoked from C programs by calling a library procedure . . . The library procedure . . . executes a TRAP instruction to switch from user mode to kernel mode and start execution . . . .
  3. [Context switch#User and kernel mode switching]
  4. Book: Chia-Che . Tsai . Arora . Kumar-Saurabh . Bandi . Nehal . Jain . Bhushan . Jannen . William . John . Jitin . Kalodner . Harry . Kulkarni . Vrushali . Oliviera . Daniela . Porter . Donald E. . Proceedings of the Ninth European Conference on Computer Systems . Cooperation and security isolation of library OSes for multi-process applications . 2014 . 1–14 . 10.1145/2592798.2592812 . 9781450327046 . 10.1.1.589.1837 . 13771821 . 2015-08-31 . 2016-03-04 . https://web.archive.org/web/20160304072634/http://www3.cs.stonybrook.edu/~porter/pubs/tsai14graphene.pdf . dead .
  5. Web site: Why Unikernels Can Improve Internet Security. 31 August 2015. April 2015.
  6. Madhavapeddy. Anil. Mortier. Richard. Charalampos. Rotsos. Scott. David. Singh. Balraj. Gazagnaire. Thomas. Smith. Steven. Hand. Steven. Crowcroft. Jon. Unikernels: Library Operating Systems for the Cloud. SIGPLAN Notices (ASPLOS 13). 48. 461. 4. March 2013. 10.1145/2499368.2451167.
  7. Kaloper-Meršinjak . David . Mehnert . Hannes . Madhavapeddy . Anil . Sewell . Peter . 2015 . Not-Quite-So-Broken TLS: Lessons in Re-Engineering a Security Protocol Specification and Implementation . Proceedings of the 24th USENIX Security Symposium (USENIX Security 15) .
  8. Thibault. Samuel. Deegan. Tim. Improving Performance by Embedding HPC Applications in Lightweight Xen Domains. 2nd Workshop on System-level Virtualization for High Performance Computing (HPCVIRT'08). 2008. 10.1145/1435452.1435454.
  9. Madhavapeddy. Anil. Mortier. Richard. Sohan. Ripduman. Gazagnaire. Thomas. Hand. Steven. Deegan. Tim. McAuley. Derek. Crowcroft. Jon. Turning Down the LAMP: Software Specialisation for the Cloud. Proceedings of the 2nd USENIX Conference on Hot Topics in Cloud Computing. 2010.
  10. Book: Martins. Joao. Mohamed. Ahmed. Raiciu. Costin. Huici. Felipe. Proceedings of the second ACM SIGCOMM workshop on Hot topics in software defined networking . Enabling fast, dynamic network processing with clickOS . 67–72. 2013. 10.1145/2491185.2491195. 9781450321785. 12514038 .
  11. Book: Kuenzer. Simon. Bădoiu. Vlad-Andrei. Lefeuvre. Hugo. Santhanam. Sharan. Jung. Alexander. Gain. Gaulthier. Soldani. Cyril. Lupu. Costin. Teodorescu. Ştefan. Răducanu. Costi. Banu. Cristian. Proceedings of the Sixteenth European Conference on Computer Systems . Unikraft: fast, specialized unikernels the easy way. 2021-04-21. https://dl.acm.org/doi/10.1145/3447786.3456248. en. Online Event United Kingdom. ACM. 376–394. 10.1145/3447786.3456248. 978-1-4503-8334-9. 2104.12721. 241528818 .
  12. Web site: Just-in-Time Summoning of Unikernels (v0.2). Magnus Skjegstad. 30 August 2015.
  13. Web site: Zerg. Zerg — an instance per request demo. 30 August 2015.
  14. Madhavapeddy. Anil. Leonard. Thomas. Skjegstad. Magnus. Gazagnaire. Thomas. Sheets. David. Scott. David. Mortier. Richard. Chaudhry. Amir. Singh. Balraj. Ludlam. Jon. Crowcroft. Jon. Leslie. Ian. Jitsu: Just-In-Time Summoning of Unikernels. The 12th USENIX Conference on Networked Systems Design and Implementation (NSDI). 2015. 978-1-931971-218.