Symfony Vs Express: a Server-Side Framework Comparison

Symfony Vs Express: a Server-Side Framework Comparison

1 Symfony vs Express: A Server-Side Framework Comparison Magnus Greiff Andr´e Johansson Faculty of Computing Blekinge Institute of Technology SE–371 79 Karlskrona, Sweden urn:nbn:se:bth-17945 2 This thesis is submitted to the Faculty of Computing at Blekinge Institute of Tech- nology in partial fulfillment of the requirements for the bachelor degree in Software Engineering. The thesis is equivalent to 10 weeks of full time studies. Contact Information: Author(s): Magnus Greiff mangegreiff@gmail.com Andr`e Johansson [email protected] University Advisor: Kenneth Lewenhagen Department of Computer Science and Engineering Faculty of Computing Blekinge Institute of Technology SE–371 79 Karlskrona, Sweden Internet : www.bth.se Phone : +46 455 38 50 00 Fax : +46 455 38 50 57 3 Abstract Context Considering the rising popularity of Node.js and the fact that a very large percentage of websites today are based on PHP, there is a need to understand the similarities and differences between these languages. Comparing their most popular server-side frameworks is valuable to developers in seeing the advantages of using one over the other - for both user and developer. Objectives In this study we investigate how Express.js and Symfony compare against each other in terms of installation, functionality and performance. This will provide understanding of when to use JavaScript frameworks and when to use PHP frameworks for server-side projects. Method A literature study was done to answer what similarities and differences exist between the frameworks. To explore how they compare in performance when mul- tiple users are actively sending requests to the server, an experiment was performed. Another experiment was carried out to measure performance in CPU-intensive ap- plications. Results The result shows that both frameworks are quick to install and it is a fast process to setup a basic application. Both frameworks are highly cuztomizable and configurable because they are supported by a big open source community and the only difference is that Express is supportive of single-page applications which Sym- fony can not do on its own. Express was better than Symfony to handle multiple concurrent users when it comes to CPU usage and time it takes for the requests. For 100 and 1000 requests, Express CPU usage varied more than Symfony, but at 10000 and 100000 it varied less. In all tests with concurrent users, Express was faster. Tests performed in the second experiment showed that Symfony is only able to use 1 core when making the requests while Express is able to use multiple cores. Even though Symfony was limited by 1 core it was faster, most likely because it used more memory. Conclusions This study shows that there are more similarities than differences between Express and Symfony. They both strive for high customization and high flexibility with a goal to make tedious tasks easier for the developer. Both rely on open source modules and components to add additional functionality. Out of the box, Express comes with less functionality as it strives to be minimalistic. However, to install Symfony is slightly quicker than Express and requires no code. There are currently more daily downloads of Express than Symfony, and therefore it’s considered more popular. It’s supportive of JavaScript-only for front- and back-end and is able to handle more concurrent users than Symfony, and is therefore better for high-traffic websites. But Symfony is able to handle CPU-intensive applications better than Express, and is able to load in large data sets faster, making it a good choice for applications with a lot of data and high CPU usage. Keywords: Symfony, Express.js, PHP, JavaScript 4 Glossary PHP - ”[...] is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.”[1] JavaScript - According to Mozilla, ”JavaScript is a scripting or programming lan- guage that allows you to implement complex things on web pages”[2] Asynchronous - Executing different parts of the code at the same time[3]. Synchronous - Executing code line by line, only executing the next line of code when the current has finished[3]. Scalability - ”Easiness to upgrade when your number of incoming request in- creases”[4]. Content Management System (CMS) - ”[...] is a software application or set of related programs that are used to create and manage digital content.”[5] Single-Page Application (SPA) - An application where application code is only loaded on the initial request to the server[6]. Object Relational Mapping (ORM) - A way of writing SQL queries using object- oriented programming[7]. Model-View-Controller (MVC) - ”MVC is a framework for thinking about pro- gramming, and for organizing your program’s files.”[8] Middleware - ”[...]functions executed in the middle after the incoming request then produces an output[...]”[9] Contents 1 Introduction 7 1.1Background................................ 7 1.2Scope................................... 8 1.3Purpose.................................. 9 2 Research questions 10 2.1Literaturestudy.............................. 10 2.1.1 Motivation............................. 10 2.1.2 Expectation............................ 11 2.2Experiments................................ 11 2.2.1 Experiment1Motivation..................... 11 2.2.2 Experiment1Expectation.................... 12 2.2.3 Experiment2Motivation..................... 13 2.2.4 Experiment2Expectation.................... 13 3 Research Method 14 3.1Literaturestudy.............................. 14 3.1.1 Searchstrategy.......................... 14 3.1.2 Backward snowballing in iterations ............... 15 3.1.3 Limitations and criteria ..................... 15 3.2Experiments................................ 15 3.2.1 Preparation............................ 15 3.2.2 Experiment1........................... 18 3.2.3 Experiment2........................... 19 3.2.4 Validity threats .......................... 20 4 Literature review 21 4.0.1 Literature............................. 21 4.0.2 Literaturecomparison...................... 23 5 Result, Analysis & Discussion 24 5.1Result................................... 24 5.2Analysis.................................. 32 5.2.1 Literature............................. 32 5.2.2 Experiments............................ 38 5.3Discussion................................. 40 6 Conclusion 42 5 Contents 6 7 Future works 43 References 44 8 APPENDICES 48 8.1 Appendix A, Links ............................ 48 8.1.1 Express Application ....................... 48 8.1.2 Symfony Application ....................... 48 8.1.3 Bombardier............................ 48 8.1.4 SQLfileforresettingdatabase.................. 48 8.1.5 ScriptforgeneratingSQLinsertfile............... 48 8.1.6 Expressroute........................... 48 8.1.7 SymfonyController........................ 48 8.2 Appendix B, Commands ......................... 49 8.2.1 Bombardiercommand...................... 49 8.2.2 Symfonywatchcommand.................... 49 8.2.3 Symfonygrepcommand..................... 49 8.2.4 Nodetopcommand........................ 49 8.2.5 Nodegrepcommand....................... 49 Chapter 1 Introduction 1.1 Background It used to be that PHP and JavaScript worked together in order to create dynamic web pages[10]. JavaScript would handle the client-side tasks in the browser while PHP handled all the server-side tasks[10]. With the increasing popularity of JavaS- cript it has become more common to use it for server-side communication as well, through Node.js, which allows JavaScript code to be executed on server-side, remov- ing the need for any PHP at all[10]. However, both platforms continue to expand and improve, and while there are many who believe “JavaScript everywhere” is better, there are just as many who believe in the stability of PHP[10]. For a long time, PHP was the only option for back-end development, and 2018 stat- istics show that it is still the most commonly known and used language for server-side scripting[11]. In 2018, more than 80% of websites are built with PHP[11]. This is likely because the PHP syntax is simple, it can be easily integrated with HTML and has a large community that offers a lot of support[12]. That makes it the go-to language for beginner programmers[12]. Similarly, JavaScript was for a long time only used for the front-end - handling the browser-side of things[13]. In 2009, Node.js was created[11] to allow developers to use a single programming language for both client- and server-side[13]. However, despite the rising interest in JavaScript as shown in Figure 1.1, only 0,4% of websites were built with Node.js in 2018[11]. The main advantage of Node.js is that it’s asynchronous, making it naturally faster than a synchronous application[3]. PHP, however, is synchronous by nature and therefore Node.js should have the advantage in speed and load times[3]. This makes Node.js ideal for scalable server-side, real-time and single-page applications, while PHP remains popular in CPU-heavy applications and Content Management Sys- tems (CMS) like Wordpress[15]. Often, frameworks are used in both languages as it makes applications easier to setup, faster to develop and more scalable[16]. For Node.js, the most popular frameworks are Express.js, Koa.js and Sails.js[16]. In PHP, it is Laravel, Symfony and CakePHP that are the most popular[16]. 7 CHAPTER 1. INTRODUCTION 8 Figure 1.1: PHP (Blue) vs JavaScript (Red) web searches past 5 years [14] 1.2 Scope The frameworks that we are going to focus on are Symfony (PHP)

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    49 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us