使用memcache(d)过早优化?

时间:2022-02-02 03:54:27

I'm working on a web app that's not even online yet. Is implementing memcache or memcached as of right now a bit premature? Should I use it only if:

我正在开发一个甚至还没有在线的网络应用程序。现在实现memcache或memcached有点过早了吗?我应该只在以下情况下使用它:

  • the web app is up, and
  • 网络应用程序已启动,并且

  • the database is having a poor performance due to a high traffic/load?
  • 由于流量/负载较高,数据库性能较差?

Or is better to implement during development?

或者在开发过程中更好地实现?

Also, in which cases is using a caching interface unnecessary or even disencouraged?

此外,在哪些情况下使用缓存接口是不必要的甚至是不鼓励的?

3 个解决方案

#1


4  

Know Your Problem Space

See memcached's own wiki:

查看memcached自己的wiki:

Can using memcached make my application slower?

可以使用memcached使我的应用程序变慢吗?

Yes, absolutely. If your DB queries are all fast, your website is fast, adding memcached might not make it faster.

是的,一点没错。如果你的数据库查询都很快,你的网站很快,添加memcached可能不会让它更快。

Get It Working First

Any optimization before you have a stable, working product is premature. You'll spend all your time fiddling with knobs that have zero performance impact on your application.

在拥有稳定的工作产品之前进行任何优化都为时过早。您将花费所有时间摆弄对您的应用程序没有性能影响的旋钮。

Your best bet is to get it into a working state and then do several things:

你最好的选择是让它进入工作状态,然后做几件事:

Profile performance

Until you gather performance data you'll have no idea where your bottlenecks truly are. Most likely they're in areas you haven't considered.

在收集性能数据之前,您根本不知道瓶颈究竟在哪里。很可能他们在你没有考虑的领域。

Identify Optimization Payoffs

Evaluate each problem area for potential performance improvements. Prioritize the areas that will give you the best ROI (return on investment). In some cases the best ROI may be more hardware.

评估每个问题区域以获得潜在的性能改进。优先考虑能够带来最佳投资回报率(投资回报率)的领域。在某些情况下,最佳ROI可能是更多硬件。

Implement Optimizations

Once you've identified what needs to be optimized, create a plan and implement it.

一旦确定了需要优化的内容,请创建计划并实施。

Sources

#2


0  

Not at all, memcache is just an external storage (which is fast and distributed),
no more or no less

完全没有,memcache只是一个外部存储(快速和分布式),不多也不少

Also, in which cases is using a caching interface unnecessary or even disencouraged?

此外,在哪些情况下使用缓存接口是不必要的甚至是不鼓励的?

probably should not use for crucial data, such as a transaction

可能不应该用于关键数据,例如交易

#3


0  

Actually, this question has two answers:

实际上,这个问题有两个答案:

First, as Will Bickford mentioned, is that you have to avoid premature optimization. You have to have a working application to determine places that may benefit from performance improvements. Only after that you can try to apply caching.

首先,正如Will Bickford所提到的那样,你必须避免过早优化。您必须拥有一个可用的应用程序来确定可能从性能改进中受益的位置。只有在那之后你才可以尝试应用缓存。

Second is designing your application for future load. This means that before you start coding, you should try to answer this question: "How will my design change if the application must handle load, let's say, 10,000 times more than it is planned now?" This usually leads to a more advanced (as in though-through) design that accommodates scaling to multiple servers, and with that comes the need to share state between the servers, hence the distributed caching. If you don't answer this question, there is a good chance you'll have to re-write your application sooner or later.

其次是为未来负载设计应用程序。这意味着在开始编码之前,你应该尝试回答这个问题:“如果应用程序必须处理负载,我的设计会如何改变,比如说现在计划的数量是现在的10,000倍?”这通常会导致更高级(如通过)设计,适应多个服务器的扩展,并且需要在服务器之间共享状态,因此需要分布式缓存。如果您不回答这个问题,您很可能迟早要重新编写您的申请。

In other words, design for future, implement for today.

换句话说,为未来设计,为今天实施。

Hope this helps.

希望这可以帮助。

Slava Imeshev

#1


4  

Know Your Problem Space

See memcached's own wiki:

查看memcached自己的wiki:

Can using memcached make my application slower?

可以使用memcached使我的应用程序变慢吗?

Yes, absolutely. If your DB queries are all fast, your website is fast, adding memcached might not make it faster.

是的,一点没错。如果你的数据库查询都很快,你的网站很快,添加memcached可能不会让它更快。

Get It Working First

Any optimization before you have a stable, working product is premature. You'll spend all your time fiddling with knobs that have zero performance impact on your application.

在拥有稳定的工作产品之前进行任何优化都为时过早。您将花费所有时间摆弄对您的应用程序没有性能影响的旋钮。

Your best bet is to get it into a working state and then do several things:

你最好的选择是让它进入工作状态,然后做几件事:

Profile performance

Until you gather performance data you'll have no idea where your bottlenecks truly are. Most likely they're in areas you haven't considered.

在收集性能数据之前,您根本不知道瓶颈究竟在哪里。很可能他们在你没有考虑的领域。

Identify Optimization Payoffs

Evaluate each problem area for potential performance improvements. Prioritize the areas that will give you the best ROI (return on investment). In some cases the best ROI may be more hardware.

评估每个问题区域以获得潜在的性能改进。优先考虑能够带来最佳投资回报率(投资回报率)的领域。在某些情况下,最佳ROI可能是更多硬件。

Implement Optimizations

Once you've identified what needs to be optimized, create a plan and implement it.

一旦确定了需要优化的内容,请创建计划并实施。

Sources

#2


0  

Not at all, memcache is just an external storage (which is fast and distributed),
no more or no less

完全没有,memcache只是一个外部存储(快速和分布式),不多也不少

Also, in which cases is using a caching interface unnecessary or even disencouraged?

此外,在哪些情况下使用缓存接口是不必要的甚至是不鼓励的?

probably should not use for crucial data, such as a transaction

可能不应该用于关键数据,例如交易

#3


0  

Actually, this question has two answers:

实际上,这个问题有两个答案:

First, as Will Bickford mentioned, is that you have to avoid premature optimization. You have to have a working application to determine places that may benefit from performance improvements. Only after that you can try to apply caching.

首先,正如Will Bickford所提到的那样,你必须避免过早优化。您必须拥有一个可用的应用程序来确定可能从性能改进中受益的位置。只有在那之后你才可以尝试应用缓存。

Second is designing your application for future load. This means that before you start coding, you should try to answer this question: "How will my design change if the application must handle load, let's say, 10,000 times more than it is planned now?" This usually leads to a more advanced (as in though-through) design that accommodates scaling to multiple servers, and with that comes the need to share state between the servers, hence the distributed caching. If you don't answer this question, there is a good chance you'll have to re-write your application sooner or later.

其次是为未来负载设计应用程序。这意味着在开始编码之前,你应该尝试回答这个问题:“如果应用程序必须处理负载,我的设计会如何改变,比如说现在计划的数量是现在的10,000倍?”这通常会导致更高级(如通过)设计,适应多个服务器的扩展,并且需要在服务器之间共享状态,因此需要分布式缓存。如果您不回答这个问题,您很可能迟早要重新编写您的申请。

In other words, design for future, implement for today.

换句话说,为未来设计,为今天实施。

Hope this helps.

希望这可以帮助。

Slava Imeshev