持续性无知可以规模化吗?
我简要了解了 NHibernate 和 Linq2Sql。 我还打算了解一下实体框架。
当我谈论这些 ORM 时,提出的问题是“它们无法扩展”,那么它们可以吗? 从谷歌我得到的印象是他们能够很好地扩展,但最终我认为必须付出代价,是否值得为更丰富、更简单的业务层付出代价。
I've been having a brief look at NHibernate and Linq2Sql. I'm also intending to have a peek at Entity Framework.
The question that gets raised, when I talk of these ORM's is "They can't scale", so can they? From Google I get the impression they're able to scale well, but ultimately I suppose there must be a price to pay, Is it worth paying for a richer simpler business layer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是一个很好的问题,恕我直言,他们可以像任何自定义 DAL 一样进行扩展。 我只使用过 nHibernate,因此我将只关注它以及它具有的有助于扩展系统的功能。
话虽如此,我认为最初调整自定义 DAL 层会更容易,因为您熟悉它的构造并且可以对其进行微调; 然而,一个好的 ORM 会提供大量的钩子,让你可以进行相当多的优化。 你只需要花一些时间学习它。
我还认为,如果您有性能关键的代码区域,并且无法让 ORM 在您的要求范围内工作,那么对于应用程序的这一小区域,您可以自定义构建自己的 DAL 层。 如果您使用的是不错的设计模式,例如工厂创建的存储库,那么您需要做的就是交换存储库的实现
This is a good question, and IMHO they can scale just as well as any custom DAL. I've only used nHibernate so I will focus only on it and the features it has which can help scale a system.
Now with that said, I think it is easier to initially tweak a custom DAL layer because your are intimate with its construction and can fine tune it; however, a good ORM will provide plenty of hooks that allow you to optimize quite a bit. You just need to spend some time learning it.
I also feel that if you have a performance critical area of code and you can't get your ORM to work within your requirements then for that tiny area of your application you can custom build your own DAL layer. If you're using a decent design pattern such as a Repository created by a factory, then all you need to do is swap out the implementation of your repository
Hibernate Shards 正在移植到 NHibernate,这将允许水平缩放。
还有一些非常酷的黑客,例如 这个来实现分片。
所以答案是肯定的,NHibernate 可以以一种持久性无知且完全透明的方式进行扩展。
Hibernate Shards is being ported to NHibernate, which will allow for horizontal scaling.
There are also some very cool hacks like this one to implement sharding.
So the answer is yes, NHibernate can scale, in a persistance-ignorant and fully-transparent way.
说在 ORM 中构建的应用程序不能很好地扩展是完全错误的。 当然,以前也曾发生过粗心或懒惰的开发人员通过编写生成极其低效的 SQL 的代码来滥用 ORM 的情况。 构建高性能应用程序意味着了解所有可爱的抽象在幕后的实际用途。 然而,要避开这个陷阱并不需要太多的时间。 使用 ORM 并不意味着永远不要打开 SQL Profiler 或 NHibernate Profiler。
关于 SP 速度更快的说法,请阅读此 和这个。 此外,ORM(至少是NHibernate)为您提供了非常简单的方法来使用SP(如果您需要的话)。
It's simply incorrect to say that apps built in an ORM do not scale well. Certainly it has happened before that careless or lazy devs abuse an ORM by writing code that generates horribly inefficient SQL. Building performant apps means understanding something about what all the lovely abstractions actually do under the hood. It does not take much to stay out of this trap however. Using an ORM doesn't mean never opening SQL profiler or NHibernate Profiler.
And regarding the claim that SPs are just a whole lot faster, read this and this. And besides, ORMs (NHibernate, at least) give you pretty easy ways to use SPs if you ever need to.