EngineYard Blog 10/13 發表的一篇文章:Rails in the Wild: 5 Client-Side Performance Observations
五個重點:
1. It’s easy to forget to compress your JavaScript and CSS
要記得 :cache => true
2. Watch out for slow third party services
都是慢在第三方
3. Using multiple image hosts doesn’t always mean higher performance
拆那麼多台未必會比較快
4. S3 is NOT a Webserver!
S3 是 storage ,不是 web server。所以不要一股腦的把東西往上丟,要注意有沒有敏感資訊,而且 s3p 是沒有幫忙做 gzip 的。
5. Most performance variability is NOT attributable to page factors
速度慢通常是慢在後端..
目前分類:Scaling Tips (6)
- Oct 16 Fri 2009 14:34
[Scale] Scale Frontend 應該注意的五件事
- Oct 14 Wed 2009 18:50
[Scale] 使用不同 backend 做 Cache
在開發時,使用 partial 是相當簡潔以及迅速的做法。但這會帶來一個壞處。造成相當多的 db query 以及 render :partial 這個行為帶來的 slow down。
解法是,在 controller 下 find all 時,順便下 :include ,把相關的 model 都拉一拉回來。
至於 partial 這部份,就使用 fragment cache 的做法,把 html 丟進 memcache ..XD。時間到 expire 掉。
這樣噴頁面速度就會相當快。
目前我使用的是 Handcache + Moneta。
Moneta supports 相當多的 backend
* File store for xattr
* Basic File Store
* Memcache store
* In-memory store
* The xattrs in a file system
* DataMapper
* S3
* Berkeley DB
* Redis
* SDBM
* Tokyo
* CouchDB
- Oct 14 Wed 2009 18:46
[Scale] Rails 接 cluster db
使用 Data Fabric 這個 gem。
這個 gem 的想法是建一個 proxy,先去問 mapping table,然後要資料時 reset db connection 去該負責的 db 拿資料。
- Oct 14 Wed 2009 18:44
[Scale] Rails Application 接兩個以上的 db
然後在 lib/tasks/dev.rake 裡寫 override db:create; db:drop 的 rake; 確保重建資料時一致
- Oct 04 Sun 2009 17:31
[Trick]多重 asset_host
可指定 asset_host 為 http://asset%d.example.com
或
Yehuda 在 WindyCindyRails 2009 分享的技巧。
- May 28 Thu 2009 20:27
[Scale] Scaling Rails Application 的五個小技巧
。
1) Cache, cache, cache and more cache.
能 Cache 的盡量 cache,不論是 Client Caching 或者是 Server-side Caching。
2) Segregate data and data serving
別為了方便就只用一個 DB 硬撐。把靜態檔案能扔上 CDN (S3, Akamai ...)的就扔。一些特定的簡單 model 可以考慮拆開用 key-value 的 data store 作...
3) Minimize & handle external dependencies
降低對於 external sites 的 dependencies, 例如抓外界 RSS 這件事,因為太不可預期了....
4) Tend your database and your job handlers
檢視 SQL Query 與 背景工作所消耗的資源量...
5) Shard your unavoidably relational data
對 DB 作 Sharding 。