First of all, it looks like I'm off by a factor of 10 in my
calculation. 262MB * 7.5M / 65389 is actually ~30GB. That also means
my estimate of 50 GB for the whole dataset is also wrong -- I'll have
to run some more experiments on this, but it seems like I can get away
with less hardware.
The hazelcast version is 1.7.1
My code reads data out of a database, so it's not quite "portable" as
a test case, but I can try to make a version that creates dummy data
and post that.
My entries are straightforward beans:
public class MyBean implements com.hazelcast.nio.DataSerializable {
String s; long n;
... (there are 20 properties of types long,String,float)
public void writeData(DataOutput out) throws IOException {
out.writeUTF(s); out.writeLong(n); ...
}
public void readData(DataInput in) throws IOException {
s = in.readUTF(); n = in.readLong(); ...
}
}
The code that puts entries into the map looks like this:
IMap<String, Data> map = Hazelcast.getMap("mymap");
com.hazelcast.nio.Serializer ser = new Serializer();
long n = 0;
long totalSize = 0;
while (rs.next()) {
MyBean bean = new MyBean(rs.getString(1), rs.getLong(2), ...);
Data data = ser.writeObject(bean);
Data old = map.get(bean.s);
if (old == null || !old.equals(data)) {
map.put(bean.s, data);
n++;
totalSize += data.size();
}
}
System.out.println("n=" + n + " totalSize=" + totalSize);
That last println() statement is where I got the 65389 number and the
aversage size of 1100 bytes.
I start up the application with -Dcom.sun.management.jmxremote and
connect jconsole to each instance. In jconsole's "Memory" tab, I look
size of the memory pool "PS Old Gen" to determine the memory use.
Before each reading, I invoke the garbage collector (Full GC) to get
rid of garbage and move all the surviving objects to the Old Gen pool.
I realize that I'm counting _all_ the memory that's used, not only the
memory that's used to hold the map itself. However, when the app
first starts up, it uses 8.7MB. I guess I can subtract that memory (5
jvms * 8.7 MB = 43.5MB) from my previous calculation, which takes it
from 262MB to 218.5 MB. Then I can extrapolate the total heap size
needed to 218.5 * 7.5M / 65389 = ~25 GB, but I would also have to add
in at least 8.7MB overhead for each JVM I would run.
I'll keep working on this.
-erik
On Dec 8, 7:01 pm, Talip Ozturk <
ta...@hazelcast.com> wrote:
> Erik,
>
> What version of Hazelcast?
>
> Can you post the code that puts up 65389 records with 1100-byte-values
> and measures the memory used?
>
> Regards,
> -talip
>