Developing, and running an API Gateway in the cloud using a unikernel operating system Jehans Jr Storvik Master’s Thesis Spring 2016 Developing, and running an API Gateway in the cloud using a unikernel operating system JehansJrStorvik May23,2016 ii Preface Acknowledgements • Mother and father - Thanks for leading me onto the path of higher education. • Kyrre Begnum - Thanks for being my supervisor for this thesis, and for making me apply to the Network and System Administration masterscoursebackduringmybachelorsdegree. • AlfredBratterud, andallthedevelopersofIncludeOS-Thanksfor allhelp,troubleshooting,andcodeexamplesprovidedforthethesis. • AllothersupervisorsatHiOAandUiO-Thanksforcreatingagreat study,andlearningenvironmentwithintheareaofInformatics. • Allstudentsinmyclass-Icouldnothaveaskedforabettertimeat HiOA.Thanks! iii iv Abstract Microservices in the cloud has become an increasingly popular platform to run services on. However, general purpose operating systems found within most VMs in the cloud use more resources than necessary. The proposed solution to these problems are running the services using unikernels. Unikernels are specialised library operating systems designed for a single purpose. However, unikernels are still relatively new, meaning that the outcome of running microservices in the cloud using unikernels are unknown. Two API Gateway services were created, and run in the cloud using Ubuntu and IncludeOS. Several experiments were conducted to test the latter two, and the data compared. An analysis on the development process, and a feature analysis with other cloud services was done aswell. Ubuntu was declared as the current best alternative to run services on in the cloud in this thesis. Yet, IncludeOS proved to work for running microservices in the cloud, and showed some promising features such as 0 CPU during idle, low memory footprint, and 13,9% more efficient in terms of CPU usage at handling 1000 client connections per second than Ubuntu. v vi Contents 1 Introduction 1 1.1 Problemstatement . . . . . . . . . . . . . . . . . . . . . . . . 2 2 Background 3 2.1 Operatingsystems . . . . . . . . . . . . . . . . . . . . . . . . 3 2.1.1 Generalpurpose . . . . . . . . . . . . . . . . . . . . . 3 2.1.2 Unikernel . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.1.3 IncludeOS . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.1.4 Relevantresearchonunikernels . . . . . . . . . . . . 5 2.2 ApplicationProgrammingInterface(API) . . . . . . . . . . . 5 2.3 APIGateway. . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.4 CloudComputing . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.4.1 Cloudenvironment . . . . . . . . . . . . . . . . . . . . 7 2.4.2 Microservicesinthecloud . . . . . . . . . . . . . . . . 7 2.5 Virtualization . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.5.1 FullVirtualizationusingbinarytranslation . . . . . . 8 2.5.2 Hardwareassistedvirtualization . . . . . . . . . . . . 8 2.5.3 Paravirtualization . . . . . . . . . . . . . . . . . . . . 8 2.5.4 VirtualMachineMonitor . . . . . . . . . . . . . . . . 9 2.5.5 VirtualMachine . . . . . . . . . . . . . . . . . . . . . . 9 2.5.6 ProgrammableTimerInterrupt . . . . . . . . . . . . . 10 2.5.7 Qemu . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.5.8 KVM . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.6 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.6.1 Netbeans . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.6.2 C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.6.3 Git . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.6.4 Httperf . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.6.5 POSIXNetworkinglibrary . . . . . . . . . . . . . . . 11 3 Approach 13 3.1 Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.2 Designstage . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.2.1 Functionalityforservice . . . . . . . . . . . . . . . . . 14 3.2.2 Cloudenvironmentforservice . . . . . . . . . . . . . 15 3.3 Implementationstage . . . . . . . . . . . . . . . . . . . . . . . 15 3.3.1 Multiplatform . . . . . . . . . . . . . . . . . . . . . . . 15 vii 3.3.2 Implementationtools. . . . . . . . . . . . . . . . . . . 15 3.3.3 PrototypeoftheAPIGateway . . . . . . . . . . . . . 16 3.3.4 Testingtheimplementation . . . . . . . . . . . . . . . 17 3.4 Designofexperiments . . . . . . . . . . . . . . . . . . . . . . 17 3.4.1 Experimentscripts . . . . . . . . . . . . . . . . . . . . 17 3.4.2 Dataanalysis . . . . . . . . . . . . . . . . . . . . . . . 18 4 Design 21 4.1 APIGateway. . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 4.1.1 Lowlevelfunctionality . . . . . . . . . . . . . . . . . 22 4.1.2 SupportedAPIs . . . . . . . . . . . . . . . . . . . . . . 24 4.1.3 Configuration . . . . . . . . . . . . . . . . . . . . . . . 24 4.1.4 Monitoring . . . . . . . . . . . . . . . . . . . . . . . . 25 4.1.5 VirtualAPI . . . . . . . . . . . . . . . . . . . . . . . . 26 4.1.6 Security . . . . . . . . . . . . . . . . . . . . . . . . . . 26 4.1.7 Performance . . . . . . . . . . . . . . . . . . . . . . . . 28 4.2 Prototyping . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 4.3 Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 4.3.1 Experimentenvironment . . . . . . . . . . . . . . . . 31 4.3.2 Experimentscript-DataGatherer.py . . . . . . . . . . 33 4.3.3 Experiment1-CPUusagewhileidling . . . . . . . . 33 4.3.4 Experiment2-CPUusagewithtraffic . . . . . . . . . 34 4.3.5 Experiment3-Testingcachingfunctionality . . . . . 34 4.3.6 Experiment4-Batchprocessingwithcaching . . . . 34 5 Implementation 35 5.1 APIGatewayservice . . . . . . . . . . . . . . . . . . . . . . . 35 5.1.1 service.cpp . . . . . . . . . . . . . . . . . . . . . . . . . 36 5.1.2 apigateway.cpp . . . . . . . . . . . . . . . . . . . . . . 36 5.1.3 api.cpp . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 5.1.4 Caching . . . . . . . . . . . . . . . . . . . . . . . . . . 37 5.1.5 Loadbalancing . . . . . . . . . . . . . . . . . . . . . . 38 5.2 Experimentenvironmentinstallation . . . . . . . . . . . . . . 38 5.2.1 IncludeOSVMinstallationandconfiguration . . . . . 39 5.2.2 UbuntuVM14.04installationandconfiguration . . . 41 5.3 Testingtheimplementation . . . . . . . . . . . . . . . . . . . 42 5.4 Experimentscript-DataGatherer.py . . . . . . . . . . . . . . 44 6 Results-Analysisandmeasurements 47 6.1 DevelopingandrunningaserviceinIncludeOScomparedto Ubuntu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 6.1.1 Differenceinservices . . . . . . . . . . . . . . . . . . . 47 6.1.2 Troubleshooting . . . . . . . . . . . . . . . . . . . . . . 48 6.1.3 Programmingtheservice . . . . . . . . . . . . . . . . 48 6.1.4 Unikernelsforrunningmicroservicestiming . . . . . 49 6.2 FeatureanalysisfortheIncludeOSAPIGatewayservice . . 50 6.2.1 Varnish . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 6.2.2 Featureanalysis . . . . . . . . . . . . . . . . . . . . . . 51 viii
Description: