开发者

How do you share pre-calculated data between calls to a Rails web service?

I have a Rails app that allows users to build up a network structure and then ask questions about how to navigate around it.

When adding nod开发者_如何学Goes and connections these are just saved to the database. At the point you make a query of the network I calculate the shortest path from any node to any other node.

Constructing this in memory takes a while (something I need to fix), but once it is there, you can instantly get the answer to any of these path questions.

The question is... How do I share this network between calls to the website, so each request doesn't regenerate the paths network each time?

Note: I am hosting this on apache server using passenger (mod ruby)

Thoughts?


Could you use memcached for this data? (see ActiveSupport::Cache::Store for the Rails cache API).


One way that 37 signals does it is have the mysql/Db buffer size at XGB and have at much amount of ram/flash mem available on the server this will cache all your selects.

Ryan bates has a screen cast where he explains these concepts including database sharding master slave replication quite well which should help you in the long run ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜