opened
ddeboer
username_0
For distributing sites over servers it it’s useful (particularly for people like @username_2) to know the memory usage per site. While some memory usage metrics are only available on the Zotonic instance-level (such as atom memory use), at least for the ETS tables we can calculate the usage per site.

Let’s add an Exometer statistic to z_stats (cf. #1670) that iterates over all ETS tables, groups them per site (matching the `$sitename`) and accumulates the totals per site, and optionally per type (depcache, observers, …):

```erlang
[proplists:get_value(memory, ets:info(T)) || T <- ets:all()].
```

@mworrell Am I missing something in the memory footprint per site? What would be the overhead of the operation mentioned above?
Report memory use per site
issue
created
mmzeeman
username_1
I think you also need to count the memory of processes which handle the traffic. For busy sites that will be way higher than the volume of data in the cache. 

I don't think there is a directly available method right now to get that value. Maybe you can divide the total memory used by the total number of sessions in the node and then multiply that with the number of sessions for the site to get a better estimate.
comment
created
mmzeeman
username_1
FYI It is also always possible to loop over all processes with `erlang:processes/0` and use `erlang:process_info/1`. 

But memory is cheap. :-)
comment
created
CyBeRoni
username_2
First of all, that isn't necessarily true.

But more importantly: it's not the point.

The point is knowing whether or not you have enough of it. ENOMEM situations suck and it's incredibly useful to know what is causing them so that you can prevent them. Right now Zotonic is a bit of a black box in this regard; I know how much memory it's using in total but I don't know what parts are using what. A good start, it seems to me, is to know how much memory is used per site so I can distribute across machines and/or size those machines appropriately.
comment
created
mmzeeman
username_1
Yep, see the suggestions above.
comment
created
mmzeeman
username_1
FYI, zotonic comes with recon. This allows you to get more details on the memory usage. Find processes which use the most. See: http://www.erlang-in-anger.com

Btw, how much memory do you generally use for your server? Ours has 32 gig.
comment