First of all it makes sense to run your test in the same conditions,
I mean you have to start 2 nodes with the same config as for your web app
(for simplicity you can do that in a single JVM) and run your operations
from the same number of threads.

Another idea came to my mind is that your query result anyways will not be
exact
in case of many parallel updates. Thus may be it makes sense to issue a
query not
after every update, but only if there are no threads currently running the
same query.
I believe this approach can improve your throughput and response time (if
queries
you are running are mostly the same).

The simplistic code for Java 8 CompletableFuture can look like:

*private static final ConcurrentHashMap<String, CompletableFuture<String>>
map = new CHM<>():*

Trx trx = new Trx();
// set the the properties...

cache.put(trx.getStrId(), trx);
cache.future().listen(putFut -> {

*        String qryKey = **"query for myField = " + **trx.getMyField();*

        *CompletableFuture fut = map.putIfAbsent(qryKey, new
CompletableFuture());*



*        String res;*

*        if (fut != null) { // Such a query already running.*


*               res = fut.get();        }*
*        else {*
                String sql = "SELECT someField FROM Trx WHERE myField = ?";

                 QueryCursor<List&lt;?>> cursor = cache.query(new
                 SqlFieldsQuery(sql).setArgs(trx.getMyField()));

                 res = "" + cursor.getAll();

                 *map.remove(qryKey).complete(res);*
*         }*

        // Get back to vertx context
        context.runOnContext((v) -> {
                myHandler.reply(new JsonObject().put("result", res));
        });
});


Sergi


2015-08-27 0:16 GMT+03:00 javadevmtl <java.dev....@gmail.com>:

> Ok it's a single main now, but I canot reproduce the issue. It's because
> this
> is doing all executions serially, while in a web app there is parallel
> write
> and queries going on from multiple web requests.
>
> https://github.com/javadevmtl/ignite-for-github
>
> With 3,000,000 records inserted the avg query speed is 112000 nanoseconds
> which seems very acceptable.
>
> The code is simple it randomly generates some string to index in the model
> then it randomly picks a key uses that key to get a string and then
> executes
> an SQL query based on that indexed field.
>
> 1- Is it possible in the web scenario that there is multiple threads trying
> to write to the cache at the same time and at the same time to read there
> some contention of resources?
>
> 2- The other idea I have is to convert my model into a key/value type
> model.
> This can work but I required far more RAM to do the work. Since i have to
> store each property of my model as it's own key/value.
>
> Any thoughts?
>
>
>
> --
> View this message in context:
> http://apache-ignite-users.70518.x6.nabble.com/Re-Query-performance-tp1009p1149.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>

Reply via email to