# 如何避免设计数据库驱动的网络应用

**URL:** https://meta.discourse.org/t/how-not-to-structure-your-database-backed-web-applications/97912
**Category:** Development
**Created:** [2018年九月24日 07:38 UTC](https://meta.discourse.org/t/how-not-to-structure-your-database-backed-web-applications/97912 "2018-09-24T07:38:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mcwumbly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcwumbly/32/103861_2.png) [@mcwumbly](https://meta.discourse.org/u/mcwumbly)
#### Post date: [2018年九月24日 07:38 UTC](https://meta.discourse.org/t/how-not-to-structure-your-database-backed-web-applications/97912/1 "2018-09-24T07:38:44Z")

</div>

I just came across this **morning paper** blog post from June:: [How not to structure your database-backed web applications](https://blog.acolyer.org/2018/06/28/how-_not_-to-structure-your-database-backed-web-applications-a-study-of-performance-bugs-in-the-wild/)

> [How _not_ to structure your database-backed web applications: a study of performance bugs in the wild](https://hyperloop-rails.github.io/220-HowNotStructure.pdf) Yang et al., _ICSE’18_
> 
> This is a fascinating study of the problems people get into when using ORMs to handle persistence concerns in their web applications. The authors study real-world applications and distil a catalogue of common performance anti-patterns. There are a bunch of familiar things in the list, and a few that surprised me with the amount of difference they can make. By _fixing_ many of the issues that they find, Yang et al., are able to quantify how many lines of code it takes to address the issue, and what performance improvement the fix delivers.

Sharing it here because Discourse is one of the applications that they profiled for this paper:

> ### Finding and profiling real-world applications
> 
> The study focuses on Ruby on Rails applications, for which many large open source applications: “ _compared to other popular ORM frameworks such as Django and Hibernate, Rails has 2x more applications on GitHub with 400 or more stars than Django and Hibernate combined_ .” Six popular application categories (covering 90% of all Rails apps with more than 100 stars on GitHub) are further selected, and then the two most popular applications in each category. Resulting in the following twelve apps:
> 
> ![](https://global.discourse-cdn.com/meta/original/3X/7/d/7da6fde8234c40bdecc97320a4148881ff6726cd.jpeg)

I have’t read the actual paper yet, and while I read most of the blog post, I didn’t study it deeply. The only thing that’s jumped out at me so far with regards to Discourse is perhaps an opportunity to replace some `where.first` calls with `find_by` instead? But I again, I’ve not studied this closely, nor is my Rails knowledge good enough to know whether that claim holds merit.

In any case, I figured folks here would be better qualified to dig deeper if they care to!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2018年九月28日 07:46 UTC](https://meta.discourse.org/t/how-not-to-structure-your-database-backed-web-applications/97912/2 "2018-09-28T07:46:28Z")

</div>

@tgxworld and I also came across this a few months ago, lots of false positives in that report. We did act on some stuff the found, there was nothing particularly significant
