一句话:在 Laravel/PHP 工业应用上整理 17 种 ORM 性能反模式,并验证性能感知重构可将响应时间最多降低约 93%。
现代 Web 应用大量依赖数据库,ORM 框架虽简化开发,却可能引入性能问题。已有研究报告了不同 ORM 下的性能反模式,但其跨框架/语言可推广性,尤其对 PHP 的适用性尚不明确。本文对基于 Laravel 的工业 Web 应用开展性能感知重构,结合既有研究与实验整理出 17 种性能反模式目录并实施重构。研究发现部分反模式与重构技术是框架/语言特定的,另一些具有一般性;其性能影响高度依赖工作负载与数据库设置。评估在工业与开源应用、多种场景下进行,重构后响应时间分别最多降低 93.0% 和 93.4%。开发者更偏好百分比提升等直观指标。
Modern web applications rely heavily on databases to query and update information. To ease the development efforts, Object Relational Mapping (ORM) frameworks provide an abstraction for developers to manage databases by writing in the same Object-Oriented programming languages. Prior studies have shown that there are various types of performance issues caused by inefficient accesses to databases via different ORM frameworks (e.g., Hibernate and ActiveRecord). However, it is not clear whether the reported performance anti-patterns (common performance issues) can be generalizable across various frameworks. In particular, there is no study focusing on detecting performance issues for applications written in PHP, which is the choice of programming languages for the majority (79%) of web applications. In this experience paper, we detail our process on conducting performance-aware refactoring of an industrial web application written in Laravel, the most popular web framework in PHP. We have derived a complete catalog of 17 performance anti-patterns based on prior research and our experimentation. We have found that some of the reported anti-patterns and refactoring techniques are framework or programming language specific, whereas others are general. The performance impact of the anti-pattern instances are highly dependent on the actual usage context (workload and database settings). When communicating the performance differences before and after refactoring, the results of the complex statistical analysis may be sometimes confusing. Instead, developers usually prefer more intuitive measures like percentage improvement. Experiments show that our refactoring techniques can reduce the response time up to 93.0% and 93.4% for the industrial and the open source application under various scenarios.
DOI 原文 ·
@inproceedings{paperbot5250,
title = {An Industrial Experience Report on Performance-Aware Refactoring on a Database-Centric Web Application},
author = {Boyuan Chen and Zhen Ming Jiang and Paul Matos and Michael Lacaria},
booktitle = {ASE},
year = {2019},
doi = {10.1109/ase.2019.00066}
}