为什么调用这个方法会导致我的应用超出免费配额?

huangapple go评论66阅读模式
英文:

Why would invoking this method cause my app to go over the free quota?

问题

我遇到了一些理解上的困难。根据我所了解,我只在下面的函数中调用了datastore.Put操作(据我所知,没有索引)。它每分钟被调用9次(如果有错误,则次数可能更少)。

func SaveCurrentStatus(c appengine.Context, check *StatusCheck, ok bool, latency time.Duration, message string) {
    r := Result{
        Id:      check.Id,
        Name:    check.Name,
        Ok:      ok,
        Latency: latency,
        Message: message,
    }
    uid := datastore.NewKey(c, "Status", "", check.Id, nil)
    _, err := datastore.Put(c, uid, &r)
    if err != nil {
        c.Errorf("%s", err.Error())
        return
    }

    MemcachePut(c, fmt.Sprintf("Status-%d", check.Id), r)
}

据我理解,这应该会导致9 * 60 * 24次写操作(它们不是新实体)。这总共是每天19,960次操作,免费配额应该是0.05百万次?

是否有任何工具可以帮助我分析正在发生的情况,或者查看我不知道的某种日志?

英文:

Having trouble understanding what is going on. The only location I call datastore.Put operations (no indexes as far as I can tell) is in the function below. It is called exactly 9 times per minute (or less if something fails).

func SaveCurrentStatus(c appengine.Context, check *StatusCheck, ok bool, latency time.Duration, message string) {
	r := Result{
		Id:      check.Id,
		Name:    check.Name,
		Ok:      ok,
		Latency: latency,
		Message: message,
	}
	uid := datastore.NewKey(c, "Status", "", check.Id, nil)
	_, err := datastore.Put(c, uid, &r)
	if err != nil {
		c.Errorf("%s", err.Error())
		return
	}

	MemcachePut(c, fmt.Sprintf("Status-%d", check.Id), r)
}

It is my understanding that this should result in 96024 write operations (they are not new entities). This is a total of 19,960 operations per day, the free quota is supposed to be 0.05 million?

Are there any utilities that might help me analyse what is going on or see some sort of log of what is going on that I don't know about?

答案1

得分: 3

我对Go语言没有太多经验,但我可以告诉你,你必须明确将属性设置为未索引,否则它们默认是被索引的。每次实体写入都会包括对与实体属性关联的每个索引(升序和降序)的写入。

你可以在这里找到更多详细信息。

Google开发者控制台中,你可以检查给定实体的哪些属性使用了索引。

转到存储/云数据存储/仪表板,然后选择你选择的实体类型。它会显示所有属性以及它们的索引大小。

英文:

I do not have much experience with Go but I would say that you must explicitly set your properties to be unindexed otherwise they are indexed by default. Then each entity write also includes writes to every index (both ascendent and descendent) associated with the entity's properties.

You can find more details here.

In Google Developers Console you can check which properties of a given entity use index.

Go to the Storage / Cloud Datastore / Dashboard and as a kind select entity of your choice. It displays all properties along with their index size.

huangapple
  • 本文由 发表于 2014年7月14日 14:21:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/24730547.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定