Memcached 与 Windows 和 .NET
有没有人已经在 Windows 环境中实现了 memcached 以供生产使用? 因为我读过很多博客,所以不建议在 Windows 中运行 memcached,尤其是用于生产用途,例如 在 Windows 上运行 memcached。
还有一件事,哪个 memcached 客户端适合与 c# 和 .net 3.5 一起使用? 我发现了许多替代方案,例如 Memcached Providers @ Codeplex、Beitmemcached 和 memcached 提供商 @ Sourceforge
Is there anyone already implement memcached for production use in Windows environment?
Because many blogs that I've read, it's not recommended to run memcached in Windows especially for production use, for example running memcached on windows.
And one more thing, which memcached client that is good to use with c# and .net 3.5 ?
I've found many alternate such as Memcached Providers @ Codeplex, Beitmemcached, and memcached provider @ Sourceforge
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
为什么需要在Windows上运行memcached? 在生产环境中这是一件昂贵的事情。
如果您的代码需要在 Windows 环境中运行,请获取 Windows Memcached 客户端并与基于 *nix 的 Memcached 机器通信。
在生产环境中,在 Server 2003 或 2008 上运行 memcached 意味着您获得所有这些设备的许可证。 Linux 将为您提供 OSS 的所有优势。 TCO 将随着 Windows 上的 memcached 线性上升
编辑:
自从我写这个答案以来已经过去了大约 1.5 年,从那以后很多事情都发生了变化。 你必须注意,尤其是当达斯汀这样的人发表评论时。
以下是如何在运行的 Windows 上获取 memcached。 从 Couchbase(以前称为 Northscale)下载 Windows 版 memcached.
通常,如果您计划在同一台生产计算机上运行 memcached,您会希望在有限的内存中启动它,即定义允许使用 memcached 的最大内存。
此处 memcached 运行时最大使用量为 128 MB。 您不希望 memcached 占用网络服务器上的所有内存。
当您决定横向扩展 memcached 你需要考虑我之前所说的。 另外,压缩键值组合中的值。 Web 服务器通常消耗很少的 CPU 使用率 (2-3%),与 CPU 使用率相比,压缩为整个网络带来了很多价值。 如果您太担心正常压缩,请尝试 LZO
Why do you need to run memcached on windows? It’s an expensive affair in a production environment.
If your code needs to run in a Windows environment get a windows memcached client and talk to a *nix based memcached machine.
In a production environment running memcached on Server 2003 or 2008 would mean that you get licenses for all those boxes. Linux will offer you all the OSS benefits. TCO will rise linearly with memcached on Windows
Edit:
It’s been around 1.5 years since I wrote this answer and lot of things have changed since. You’ve to take notice, especially when someone like Dustin comments.
So here’s how you can get memcached on windows running. Download memcached for windows from Couchbase (formerly Northscale).
Typically if you plan to run memcached on the same production machine you’d want to start it in limited memory, i.e. define the maximum memory memcached is allowed to use.
Here memcached runs with a maximum of 128 mb usage. You don’t want memcached to take up all the memory on your webserver.
The moment you decided to scale out memcached you’ll need to consider what I said earlier. Additionally compress your values in the key value combinations. Web servers typically consume very little CPU (2-3%) usage and compression brings in a lot of value to network throughout in comparison to the CPU usage. If you are too concerned about normal compression, try LZO
我很惊讶这里还没人提到 Redis - 它是最重要的功能之一- 丰富且最快(在入门级 Linux 机器上每秒 110,000 SET)键值数据存储,具有对字符串、集合、列表、排序集合和散列的丰富数据结构支持。
虽然windows不是官方支持的平台,但是在windows下完美运行,所有测试都通过。 我这里有 Windows 版本(使用 Cygwin):
https://github.com/ServiceStack/ServiceStack.Redis#redis -server-builds-for-windows
它还为当今使用的几乎所有编程语言提供了客户端绑定。 我维护一个丰富的开源 C# Redis 客户端,为任何 C# POCO 类型提供本机 API 支持、事务支持和线程安全客户端管理器,这些客户端管理器已准备好放入任何 IOC 中:
https://github.com/ServiceStack/ServiceStack.Redis
I'm suprised no one here has yet to mention Redis - it is one of the most feature-rich and fastest (110,000 SET's per second on an entry level linux box) key-value data stores with rich data-structure support for strings, sets, lists, sorted sets and hashes.
Although windows is not an officially supported platform, it runs perfectly under windows with all tests passing. I have windows builds (using Cygwin) available here:
https://github.com/ServiceStack/ServiceStack.Redis#redis-server-builds-for-windows
It also has client bindings for nearly every programming language in use today. I maintain a rich Open Source C# Redis client with native API support for any C# POCO type, transaction support and Thread-safe client managers that are ready to be dropped into any IOC at:
https://github.com/ServiceStack/ServiceStack.Redis
由于当时还不存在 Velocity,因此我为我工作的公司 Skiviez 使用了 Windows 的 Memcached 端口。 它的存在主要只是为了为同一台机器上的多个工作进程提供集中式缓存。 目前,它在一个使用量不大的电子商务网站上已经正常运行了大约 18 个月(大约每天 18,500 次点击)。 我使用的客户端是 Enyim 集成为 iBATIS.NET 的缓存提供程序。 该客户端似乎工作得很好; memcached 客户端一开始也不是很复杂。
如果我必须再次这样做,如果我致力于继续使用 Windows 来使用我的分布式缓存解决方案,我可能会考虑 Velocity。 但它现在正在工作,所以我不会碰它。
(旁白:从那时起,我通过向数据库中的关键表添加某些
Cache*
列来消除对缓存的大部分需求,这些表每天晚上由计划任务更新。这最终减少了从最初查询数据库对 CPU 时间造成的压力,到随后将缓存结果保留在 memcached 中对内存可用性造成的压力,当数据的缓存版本出现时,这也使得代码中的情况变得更加明确。与即时计算版本相比,我确信您有很多理由使用分布式缓存,但退后一步并质疑您是否真的需要它总是值得的! )Since Velocity didn't exist at the time, I used a memcached port to Windows for the company that I work for, Skiviez. It mainly only exists to provide a centralized cache for multiple worker processes on the same machine. It's been running fine about 18 months now on an e-commerce site that sees modest use (~18,500 hits/day). The client that I used was Enyim integrated as a cache provider for iBATIS.NET. That client seems to work well enough; memcached clients are not very complicated to begin with, either.
If I had to do it again, I'd probably look at Velocity if I was committed to remaining on Windows for my distributed caching solution. But it's working now, so I'm not going to touch it.
(Aside: Since then, I negated most of the need for the cache by adding certain
Cache*
columns to key tables in the database that are updated by a scheduled task every evening. This ended up putting much less strain on resources all around, from the initial hit in CPU time by querying the database to the subsequential strain on memory availability by keeping the cached results sitting in memcached. It also made it much more explicit in the code when a cached version of the data is being accessed versus a calculated-on-the-fly version. I'm sure you have lots of reasons to use a distributed cache, but it's always worth a shot to take a step back and question whether or not you really need it!)我不知道您正在从事的项目是什么,但您可能想看看 Microsoft Velocity 项目
从页面:
我看过几个演示,看起来它与 .net 框架的集成非常好。
客户端 API 的问题在于,您仍然必须使用 LAMP 堆栈在另一个机器上运行一个 memcached 实例,最好是如您所指出的那样。 使用速度意味着您仍将在同一堆栈上运行,并且跨 .net 平台的集成更加紧密。
话虽如此,如果您想使用速度作为其他 .net 应用程序的缓存,您可能会发现自己必须编写自己的 API 来公开速度数据以供使用。
i don't know what the project you're working on is, but you might like to take a look at the Microsoft Velocity project
From the page:
I've seen a couple of demo's and it looks like it has really nice integration with .net framework.
The problem with the client API's is that you still have to have an instance of memcached running on another box somewhere preferrably as you've noted, using the LAMP stack. Using velocity means you're still going to be running on the same stack and there's tighter integration across the .net platform.
Having said that, if you want to use velocity as a cache for other .net applications you might find yourself having to write your own API to expose the velocity data for consumption.
Velocity 的管理难度更大,但它比 memcached 强大得多。 我并不反对memcached,一点也不反对,它很棒。 但展望未来,纯基于 .NET 的新项目会疯狂地不利用 Velocity,即使在当前未发布的状态下也是如此。
Velocity is a bit more involved to administer, but it is far, far more powerful then memcached. I am not anti-memcached, not in the least bit, it is great. But moving forward, new projects that are pure .NET based are crazy not to leverage Velocity, even in its current unreleased state.
看看SharedCache。 它是开源的、易于使用且非常可靠。
have a look at SharedCache. its open source, easy to use and very reliable.
根本不是真的。 运行 Memcached 不需要 LAMP(Linux、Apache、MySQL、PHP)堆栈。 目前我更喜欢 memcached 而不是 Velocity,直到 Velocity 超出 CTP 范围。 我已经尝试过一段时间的速度,但发现它太笨拙了。 我遵循整个 KISS 的做法,你知道……保持简单。 没有什么比缓存更简单了... Get(key)... Put(key, value)... Destroy(Key)。
Not at all true. The LAMP (Linux, Apache, MySQL, PHP) stack is not required to run Memcached. I currently prefer memcached over velocity until velocity is out of CTP. I've played around with velocity for a bit but found it too unwieldy. I follow that whole KISS thing, you know... keep it simple. Nothing simpler than caching... Get(key)... Put(key, value)... Destroy(Key).
作为上述 Velocity 的补充,这是 Microsoft 作为 AppFabric 的一部分发布的。 更多详细信息请参见此处。
在 StackOverflow 上查看涉及 AppFabric 和 Cache 的各种问题。
As an addendum to mentions of Velocity above, this was released by Microsoft as part of AppFabric. More details here.
Check out the various questions involving AppFabric and Cache here on StackOverflow.
我知道我参加聚会有点晚了,而且已经有很多好的答案了。
我们在 Windows Server 上使用 Membase 并取得了巨大成功。 它与 Memcached 100% 兼容,并且有一个很好的 GUI 安装程序和 Web 配置服务器构建它。 它非常容易管理。
还包括其他 NoSQL 功能,这些功能超出了本线程的范围,但值得一看。 他们确实拥有用于开发、测试和(有限)生产服务器的免费许可证。
Membase 下载
该页面仅提供适用于 Memcached 的 Windows 安装,如果您不需要任何Membase 中的额外功能。
I know I'm a little late to the party here, and there are already tons of good answers.
We've used Membase on Windows Server with great success. It is 100% compatible with Memcached, and has a nice GUI installer and web configuration server build it. It is extremely easy to administer.
There are also other NoSQL features included, which are outside the scope of this thread, but worth looking at. They do have a free license for development, testing, and (limited) production servers.
Membase Downloads
That same page has a Windows Install for Memcached only, if you don't want any of the extra features in Membase.
请点击下面提到的链接查看此问题的解决方案。
我可以在 Windows 环境中实现 memcached 以供生产使用。
http://www.codeproject.com/Articles/96698/Implementing -分布式缓存使用Memcached http://www.deanhume.com/Home/BlogPost/object-caching----net-4/37 http://latebound.blogspot.com/2008/10/using-memcached-from-c.html
Please follow the links mentioned below to see the solution for this question.
I could implement the memcached for production use in windows environment.
http://www.codeproject.com/Articles/96698/Implementing-Distributed-Caching-using-Memcached http://www.deanhume.com/Home/BlogPost/object-caching----net-4/37 http://latebound.blogspot.com/2008/10/using-memcached-from-c.html
如果您有兴趣在 Windows 上运行 memcached 客户端,那么还有两个额外的开源服务器可以完成这项工作。 两者都实现了标准 memcached 服务器协议并用 Java 编写,因此它们可以在 Windows 上运行。
If you're interested in running a memcached client on Windows then there are two additional open source servers that can do the job. Both implement the standard memcached server protocol and are written in Java so they run on Windows.