Google App Engine 中的最大实体大小
我正在 GAE 中开发一个投票应用程序,我希望能够支持大量选民(比如 100,000)。我担心能够在不达到实体大小上限或任何其他限制的情况下执行此操作。以下是我的实体关系的相关部分:
class Election(db.Model):
tmp_voters = db.StringListProperty(default = "")
class Voter(db.Model):
election = db.ReferenceProperty(Election, collection_name = "voters")
当用户编辑选举时,我将选民电子邮件地址列表放入名为 tmp_voters 的 StringListProperty 中。就在选举开始之前,我为每个投票者创建一个投票者实体,每个投票者实体都有对选举实体的引用。
看来对于大量选民来说,tmp_voters会导致Election实体超出限制。是这样吗?我该如何解决这个问题?使用 blob 会是一个很好的解决方案吗?
拥有大量的 Voter 实体(每个实体都引用 Election 实体)是否会导致 Election 实体太大?即,添加对选举实体的引用是否会增加选举实体的大小?
对于大量选民,我还应该担心其他限制吗? (配额除外)
I'm working on a voting application in GAE, and I would like to be able to support a very large number of voters (say 100,000). I'm concerned about being able to do this without hitting the cap on the entity size or any other limitations. Here is the relevant parts of my entity relationship:
class Election(db.Model):
tmp_voters = db.StringListProperty(default = "")
class Voter(db.Model):
election = db.ReferenceProperty(Election, collection_name = "voters")
While the user is editing an election, I put the list of voter email addresses in a StringListProperty called tmp_voters. Just before the election is started, I create a Voter entity for each voter, and each Voter entity has a reference to the Election entity.
It seems that for a large number of voters, tmp_voters will cause the Election entity to exceed the limit. Is that right? How do I fix that? Would using a blob be a good fix?
Will having a large number of Voter entities, each of which reference the Election entity, ever cause the Election entity to be too big? I.e., does adding a reference to the Election entity increase the size of the Election entity?
Any other limitations I should be concerned about with a very large number of voters? (other than quotas)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在另一个实体中添加对实体的引用对引用的实体没有任何影响,除了自动生成的反向引用查询将返回一个结果之外。
我不清楚 tmp_voters 的用途,但是,是的,如果 ListProperty 变得太大,您将会遇到问题,尽管可能与实体大小无关; ListProperty 只能包含大约 5000 个条目,并且您不会使用 1 MB 的空间来保存 5K 电子邮件地址。
Adding a reference to an entity in another entity has no effect whatsoever on the referenced entity, except that the automatically-generated backreference query will return one more result.
It's unclear to me what tmp_voters is for, but yes, if that ListProperty gets too big you will have problems, although probably not with entity size; a ListProperty can only have something like 5000 entries and you're not going to use 1 MB of space to hold 5K email addresses.
似乎更好的设计是让每个选民都包含一个他们参与的选举列表(大概很小),而不是相反。那么 Election 对象只是有关选举的元数据,而不是实际的选民列表。
当有人到达您投票时,您只需调出他们的选民条目,检查他们是否可以在选举中投票,然后保存他们的投票。
It seems like a much better design would be to have each Voter contain a (presumably small) list of Elections that they participate in, rather than the other way around. Then the Election object is just metadata about the election, not the actual list of voters.
When someone arrives you vote, you just pull up their Voter entry, check that they are allowed to vote in the Election, and save their vote.