Grpc Layer for Content Delivery in Kentico Kontent
Total Page:16
File Type:pdf, Size:1020Kb
Masaryk University Faculty of Informatics gRPC Layer for Content Delivery in Kentico Kontent Master’s Thesis Bc. Petra Rebrošová Brno, Spring 2021 Masaryk University Faculty of Informatics gRPC Layer for Content Delivery in Kentico Kontent Master’s Thesis Bc. Petra Rebrošová Brno, Spring 2021 This is where a copy of the official signed thesis assignment and a copy ofthe Statement of an Author is located in the printed version of the document. Declaration Hereby I declare that this paper is my original authorial work, which I have worked out on my own. All sources, references, and literature used or excerpted during elaboration of this work are properly cited and listed in complete reference to the due source. Bc. Petra Rebrošová Advisor: Bruno Rossi, PhD. i Acknowledgements First of all, I would like to thank my advisor Bruno Rossi, Ph.D. for his guidance, patience, providing valuable feedback and advice during the writing of this thesis. Secondly, I would like to thank my consultant Petr Švihlík for his advice and help with technical issues. Furthermore, I want to express my gratitude to my family, friends, and colleagues from Kentico for their unconditional support, patience, motivation and always being there for me. Finally, I would like to thank my partner Jakub for his support and always standing by me. iii Abstract Remote Procedure Calls (RPCs) have been popular throughout the history of machine-to-machine network communication from its beginning. gRPC protocol is a new concept of RPC invented by Google, which promises more efficient messages and their faster transfer. Ken- tico Kontent, as a Content Management System (CMS), can benefit from the utilization of gRPC in alternative content delivery to its cur- rent APIs. Because Kentico Kontent is widely used and it is essential to pro- vide as fast data transfer between client applications and Kontent as possible, it is important always to search for alternative solutions that would improve content delivery. The goals of this thesis are to analyze gRPC in line with relevant studies and documentation and evaluate it using Goal Question Metric (GQM) methodology. The results show that gRPC excels in scenarios where mobile or IoT application acts as a client, that can be also used in the omnichannel content delivery scenarios viable for Kontent. After that, a gRPC content delivery layer was designed and built as an alternative endpoint for Kontent’s Delivery API, within a sample mobile application processing the data from the implemented gRPC API endpoint. Results of the analysis prove that gRPC significantly reduces size of the messages. In scenarios with a large payload the gRPC messages are faster than the originally used HTTP messages, however, it does not apply for messages with a small payload. iv Keywords gRPC, Kentico Kontent, Content Management System, Protocol Buffer, API, .NET, REST v Contents 1 Introduction 3 1.1 Problem Statement ......................3 1.2 Thesis Goals ..........................4 1.3 Thesis Structure ........................5 2 Delivering Content in Kentico Kontent 7 2.1 Content Management System ................7 2.1.1 Headless CMS . .7 2.2 Software Delivery .......................9 2.2.1 Software-as-a-Service Paradigm . .9 2.2.2 Content-as-a-Service Paradigm . .9 2.3 Omnichannel vs. Multichannel Approach .......... 10 2.3.1 Multichannel approach . 10 2.3.2 Omnichannel Approach . 10 2.4 Content Delivery in Kentico Kontent ............. 10 2.4.1 APIs . 11 2.4.2 SDK . 13 2.4.3 Delivered Data Structures . 14 2.5 Possible Improvements for Content Delivery ......... 15 2.6 Summary ........................... 15 3 Remote Communication 17 3.1 History of Remote Communication .............. 17 3.1.1 Beginnings of Networks and Remote Commu- nication . 17 3.1.2 World Wide Web . 19 3.1.3 Web 1.0 . 20 3.1.4 Web 2.0 . 20 3.1.5 Web 3.0 . 20 3.1.6 Web 4.0 and the Future of Web . 21 3.2 Remote Communication Protocols and Frameworks ..... 21 3.2.1 REST . 21 3.2.2 HTTP . 21 3.2.3 RPC . 23 3.2.4 gRPC . 23 vii 3.3 Summary ........................... 24 4 gRPC 25 4.1 Comparison of gRPC and REST ............... 25 4.2 Design ............................. 25 4.2.1 Network Communication Principle . 26 4.2.2 Types of Communication . 26 4.2.3 Error Handling . 28 4.3 Usability of gRPC ....................... 29 4.3.1 Microservices . 29 4.3.2 Web Applications and Websites . 29 4.3.3 Mobile Applications . 30 4.3.4 IoT and Embedded Systems . 31 4.4 Requirements and Principles ................. 32 4.5 Performance .......................... 33 4.5.1 Battery Consumption . 34 4.5.2 Speed of the Requests . 34 4.6 Security ............................ 35 4.6.1 Authentication . 35 4.6.2 Vulnerabilities . 36 4.7 Reliability ........................... 37 4.8 Developer Experience ..................... 37 4.9 gRPC Utilization in Implementation ............. 40 4.9.1 Protocol Buffer . 40 4.9.2 Data Serialization and JSON Mapping . 41 4.9.3 Network Communication . 43 4.10 Summary ........................... 43 5 gRPC Analysis 45 5.1 The Goal Question Metric Approach ............. 45 5.2 Stated GQM .......................... 45 5.3 Evaluation of the Stated GQMs ................ 47 5.3.1 G1: Analyze and find the most suitable types of applications for gRPC protocol, viable for om- nichannel content delivery. 48 5.3.2 G2: Show performance benefits of using gRPC in comparison with HTTP. 50 viii 5.3.3 G3: Show Developer experience (DX) benefits of utilizing gRPC . 51 51subsection.5.3.4 5.4 Summary ........................... 53 6 gRPC Layer for Kentico Kontent 55 6.1 Migration from REST Architecture to gRPC ......... 55 6.2 Design of gRPC Content Delivery Layer in Kentico Kontent 56 6.2.1 Models . 56 6.3 API Implementation Details ................. 56 6.4 Server Application Run .................... 57 6.5 Client Application ...................... 57 6.6 Experiments .......................... 59 6.6.1 Server Device Details . 59 6.6.2 Measurements . 59 6.7 Analysis of gRPC Integration into Kentico Kontent Deliv- ery API ............................ 61 6.7.1 Stated GQM . 61 6.7.2 Evaluation of the Stated GQMs . 62 6.7.3 Conclusion of the Analysis of the Experimental Work......................... 63 6.8 Summary ........................... 63 7 Conclusion 65 7.1 Results of the Thesis Goals .................. 65 7.2 Future Work .......................... 66 Bibliography 67 A Electronic Attachments 75 B Utilized Tools and Configurations 77 B.1 C# Implementation of gRPC API ............... 77 B.2 Client Android Application .................. 77 B.3 API Testing .......................... 78 C Sample Code 79 C.1 items_service.proto ...................... 79 ix D Mobile Application Details 81 D.1 Application Screenshots .................... 82 x List of Tables 4.1 REST HTTP API and gRPC API overview (based on comparison from [46]) 39 5.1 Evaluation of GQM metrics for G1 49 5.2 Average times of gRPC and HTTP messages 50 5.3 Evaluation of GQM metrics for G3 52 5.4 Evaluation of GQM metrics for G4 53 6.1 Size of gRPC and HTTP requests and responses containing 10, 100, or 500 items retrieved from GetItems endpoints 60 6.2 Median of the measured speed of responses containing 10, 100, or 500 items retrieved from gRPC and HTTP GetItems endpoints 60 xi List of Figures 1.1 Thesis structure with highlighted thesis goals 4 2.1 Headless CMS structure, adapted from [5] 8 2.2 Kentico Kontent public APIs structure 12 4.1 Structure of gRPC on HTTP/2 27 5.1 Scheme of GQM approach 46 6.1 Structure of gRPC and HTTP Kentico Kontent Delivery API communicating locally with client mobile application 58 6.2 Comparison of execution times of gRPC and HTTP messages 61 D.1 Main screen of the implemented Android application 82 D.2 Screen of the implemented Android application displaying data from gRPC and HTTP GetItems endpoints 83 xiii Acronyms 6LoWPAN IPv6 over Low-Power Wireless Personal Area Networks. ALTS Application Layer Transport Security. API Application programming interface. CaaS Content-as-a-Service. CDN Content delivery network. CMS Content Management System. CRM Customer Relationship Management. CVSS Common Vulnerability Scoring System. DX Developer experience. ERP Enterprise Resource Planning. ESP Extensible Server Proxy. FTP File Transfer Protocol. GQM Goal Question Metric. gRPC gRPC Remote Procedure Calls. HTTP HyperText Transfer Protocol. IaaS Infrastructure-as-a-Service. IDL Interface Definition Language. IoT Internet of Things. IP Internet Protocol. IXP Internet exchange point. 1 Acronyms JWT JSON Web Token. LWM2M OMA Lightweight M2M. MQTT Message Queuing Telemetry Transport. NVD National Vulnerability Database. PaaS Platform-as-a-Service. QoS Quality-of-Service. REST Representational state transfer. RFID Radio-frequency identification infrastructure. RPC Remote Procedure Calls. SaaS Software-as-a-Service. SDK Software development kit. SLA Service-level agreement. SSL/TLS Secure Sockets Layer/Transport Layer Security. TCP Transmission Control Protocol. TLS Transport Layer Security. 2 1 Introduction In today‘s world, the number of electronic devices around us increases every day and a huge amount of data is stored and sent through the network. These devices communicate with us or with each other, they process, share or display the data. When analyzing services and applications according to their toler- ance for data loss, need for high-speed, etc., different kinds of services have different demands. There is also a difference in requirements of web, mobile, or IoT applications. A number of communication frameworks and protocols guaranteeing the fulfillment of the specific demands increase. Redesign of the product architecture or utilization of new protocols and frameworks may bring an opportunity for en- hancement, for example in the speed of the message exchange in the communication. Kentico Kontent as Content Management System (CMS) is one of several approaches to managing and providing data. For CMS it is not important only to manage and store data, but also provide data to the various systems and applications reliably and with as minimal network latency as possible [1].