数据建模:处理大量数据的技术?
因此,我有一个相对较小的网站,但数据量不断增长 - 增长最快的表是综合浏览量,因为我们自己进行所有分析。该网站是使用 VB.Net、SQL Server 2008 和 jQuery 制作的。我仅限于 .net 2.5。
我目前使用具有属性列表的对象来处理所有数据和验证。每个属性都具有特定的数据类型,并且在为其赋予新值时具有验证函数。如果数据未验证,那么它甚至不会更新数据库并向用户反馈错误。目前我有“Manager”类和“Item”类 - 项目由特定的 Manager 类管理,例如用户由 UserManager 管理,因此要获取所有用户,我只需调用 UserManager.Items。这些 Manager 类存储在缓存中并根据需要创建 - 但是一旦引用 Manager 类,它就会创建其中的所有项目。现在,随着公司的快速发展,这一速度变得相当缓慢。加载第一页(首次请求数据最多的页面)需要 2 - 3 秒,但我对这次并不满意。之后几乎是瞬间的。
现在,我认为我有 3 个选项来加快网站速度:
- 保持原样,但尝试通过其他技术提高效率;
- 更改为在每次页面加载时创建所有这些对象,希望它只是这么慢,因为我使用缓存来存储相当数量的数据(至少大约 10 MB 左右);
- 忘记使用面向对象的技术,只使用直接的 SQL 查询和循环记录。
有人对我应该使用哪种方法有任何建议吗?如果我错过了任何选项,请提出建议。
谢谢。
问候,
理查德
So I have a relatively small website with growing amounts of data - the fastest growing table is pageviews, as we do all our analytics ourselves. The website is made using VB.Net, SQL Server 2008 and jQuery. I am limited to .net 2.5.
I currently handle all the data and validation using objects with a list of attributes. Each attribute is of a specific datatype and has a validation function when a new value is given to it. If the data does not validate then it won't even get as far as updating the database and feeds back an error to the user. Currently I have "Manager" classes and "Item" classes - Items are managed by a particular Manager class, for example Users are managed by the UserManager, so to get all the users I just have to call UserManager.Items. These Manager classes are stored in the cache and are created as needed - but once a Manager class is referenced it creates all of the Items within it. This is getting rather slow now, as the company is growing fast. It takes 2 - 3 seconds to load the first page (the page which makes most first-time requests to data) but I am not happy with this time. After that it is nearly instant.
Now the way I see it I have 3 options to speed the website up:
- Keep it as it is, but try to make it more efficient through other techniques;
- Change to creating all these objects on every page load, in the hope that it is simply so slow because I am using the cache to store a fair amount of data (about 10 MB or so at least);
- Forgetting using object oriented techniques and just use straight SQL queries and loop through records.
Does anyone have any recommendations on which approach I should use? If I have missed any options then please suggest them.
Thank you.
Regards,
Richard
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为对于您的网站,您不能使用“直接访问属性”的概念:UserManager.Items。
如果您的数据量不断增长,您的管理器类应该有一个“间接访问属性”,这将是像 UserManager.GetItems() 这样的方法。因为当您创建 UserManager 类的新实例时,.NET 会计算属性 (UserManager.Items)...
恢复:删除 UserManager.Items 属性并创建 UserManager.GetItems() 方法。
I think that for your website you can't use the concept "direct access attribute": UserManager.Items.
If you have a growing amount of data you should have an "indirect access attribute" for your manager classes, that would be a method like UserManager.GetItems(). Because the .NET calculates the Proprieties (UserManager.Items) when you create a new instance of the UserManager class...
Resume: remove UserManager.Items attribute and create a method UserManager.GetItems().