简体   繁体   English

Mongodb和Django

[英]Mongodb and Django

I am currently working with two databases in my django app - mongodb for storing numeric data and mysql for handling relations and providing business domain background. 我目前在Django应用程序中使用两个数据库-mongodb用于存储数字数据,而mysql用于处理关系并提供业务领域背景。

I have one concern: 我有一个担忧:

First - I am using mongoengine along with django signals and custom tamplate tags. 首先-我正在使用mongoengine以及django信号和自定义模板模板。 Meaning: 含义:

Whenever I call this filter. 每当我叫这个过滤器。 {{myobject|do_sth:"20"}} the process goes that way: {{myobject | do_sth:“ 20”}},过程如下:

filter call -> myobject's do_sth property with argument "20" call -> send signal job_done -> receive signal job_done -> create monoengine document -> save it 过滤器调用-> myobject的do_sth属性,参数为“ 20”调用->发送信号job_done->接收信号job_done->创建monoengine文档->保存它

I dont't know if that's clear but it's just a combination of different techniques - my problem is : How is the efficiency problem in this case ? 我不知道是否很清楚,但这只是不同技术的组合-我的问题是:在这种情况下效率问题如何? Has anyone tried that solution or has similar experience ? 是否有人尝试过该解决方案或具有类似经验?

Another question: Since, I relatively often use the process described above should I be concerned about number of items in mongodb collection. 另一个问题:因为,我比较经常使用上述过程,所以我应该关注mongodb集合中的项目数。 Let's suppose it will grow up to 10 000 in a week and than we clear the collection - is that fine ? 让我们假设它会在一周内增长到10000,并且比我们清除收集的数据还好吗?

I'd suggest that is too much logic for a simple template tag and it might be better to do in the view itself - at least thats what djangonauts would argue. 我建议对于一个简单的模板标签来说,这太逻辑了,最好在视图本身中做-至少这就是djangonauts会争论的。

I take it you are outputting the results of the filter - rather than just calling the signals so data is created. 我认为您是在输出过滤器的结果-而不是仅调用信号以便创建数据。 If you aren't outputting the results then make the processing offline and non-blocking for the user. 如果您不输出结果,则使处理脱机且对用户无阻塞。 I've had great success with celery for long running / potentially blocking tasks (you dont have to complicate your stack as mongodb works great as the queue backend). 对于长期运行/可能阻塞任务的芹菜 ,我已经取得了巨大的成功(由于mongodb作为队列后端工作得很好,因此您不必使堆栈复杂化)。

MongoDB in production with masses of data across large clusters - so 10,000 documents is a relatively tiny amount of data. MongoDB在生产中具有跨大型集群的大量数据-因此10,000个文档是相对少量的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM