-
Notifications
You must be signed in to change notification settings - Fork 2
Performance Test
##JMeter
With JMeter it is possible to load test the datacore by performing request against it. We can specify the number of user, number of iteration and ramp-up period for a test.
A scenario consisting of a batch of request can be recorded by JMeter using a proxy and thus being replayed later. JMeter can also operate in a master-slave way with one instance controlling what other instances are doing.
BlazeMeter proposes JMeter in the cloud.
####Recording requests
- Proxy Settings in Spring.
<http-conf:conduit name="*.http-conduit">
<http-conf:client ProxyServer="localhost"
ProxyServerPort="8282" ProxyServerType="HTTP" AllowChunking="false" />
</http-conf:conduit>
Sometimes useful too : (With Datacore located at localhost:8081)
<!-- http-conf:conduit name="http://localhost:8081/.*"-->
Also needed in beans :
xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
xsi:schemaLocation="
http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd"
- Run tests.
To be sure, run maven tests with parameters -DproxySet
, DproxyHost
and DproxyPort
like :
mvn test -DproxySet=true -DproxyHost=localhost -DproxyPort=8282 -Dtest=DatacoreApiServerTest
##Limiting Mongo ram using cgroups
Install cgroups (on Ubuntu) :
aptitude install libcgroup1
Let's create a cgroup to apply our limitation later on.
sudo cgcreate -t <user> -a <user> -g memory,cpu:<groupname>
Limit ram available to 33M for this cgroup.
echo 33000000 > /sys/fs/cgroup/memory/<groupname>/memory.limit_in_bytes
Start mongod with the given limitations
cgexec -g memory:<groupname> mongod
It's now possible to watch how many ram is used by mongo using mongostat
or top -b | grep mongod
.
##Mongo Setup
- Insert documents in a collection using Mongo Shell.
for(var i = 1; i <= 100000; i++) {
var uriTest = "http://data.oasis-eu.org/dc/type/sample.marka.company/" + i;
db.sample.marka.company.insert({
"_class" : "org.oasis.datacore.core.entity.model.DCEntity",
"_v" : NumberLong(0),
"_uri" : uriTest,
"_mdln" : "sample.marka.company",
"_t" : [ "sample.marka.company" ],
"_crAt" : ISODate("2014-04-10T10:13:59.452Z"),
"_chAt" : ISODate("2014-04-10T10:13:59.452Z"),
"_crBy" : "admin",
"_chBy" : "admin",
"_p" : {
"field" : "http://data.oasis-eu.org/dc/type/sample.marka.field/4",
"id" : 3,
"address" : "6 boulevard Anatole France",
"website" : "exemple.com",
"name" : "Exemple",
"lastAnnualRevenue" : 100000,
"incorporationYear" : 1999,
"city" : "http://data.oasis-eu.org/dc/type/sample.marka.city/1",
"country" : "http://data.oasis-eu.org/dc/type/sample.marka.country/1",
"employeeNb" : 10
},
"_ar" : [ "u_admin" ],
"_o" : [ "u_admin" ]
});
}
- Load documents from a collection in ram.
for(var i = 1; i < 500000; i++) {
var url = "http://data.oasis-eu.org/dc/type/sample.marka.company/" + i;
var res = db.sample.marka.company.findOne({_uri: url});
}
##Defining Tests According to Kirk Pepperdine in The Box:
The list of things we need to know in order to create a good simulation includes, the number of users, what they are doing, how often they are doing it, and when they are doing it. We also need to consider scenarios such as; beginning and end of shift activities, seasonal trends, special events, the ever present 2 am backup activity.