users@grizzly.java.net

Re: proper use of the server

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Sat, 29 Mar 2014 10:52:04 -0700

Hi Aris,

On 29.03.14 06:02, Aris Alexis wrote:
>
> I couldn't find a forum so I am using this list to ask some pretty
> noob questions.
This is the right place to ask :)

> I am in the process of deciding the technology to be used in a startup
> and I will give you the specs:
>
> Social web app with mobile extensions.
> Rest backend.
> NoSQL(neo4j probably)
>
> I am trying to decide to use either grizzly or jetty, finding grizzly
> much more easy to embed.
> I build a prototype using the jersey examples with a grizzly server
> that doesn't use servlets. I do not need them, I can filter queries
> through jersey filters (and use authentication filters I guess?).
Right, Jersey Filters should be enough.

>
> I am wondering, does grizzly use a separate thread for each incoming
> request?
Grizzly has a thread-pool for processing incoming requests. Depending on
your needs you can process requests directly in the core thread-pool or
worker thread-pool.
For example static resources could be served in the core thread-pool,
because we know static resource processing is fast and non-blocking,
however for the requests, that involve DB communication it's better to
use worker-thread pool, because core threads can't be blocked.


> Are there any tricks for managing connections to the db or each thread
> should have its own connection?
Grizzly doesn't have any built-in DB support, so it's up to you to
decide either you want to have per-thread connection or different type
of DB connection pool.

> Do you think in this form grizzly could function as a server for a
> large scale application or should I use the servlet version?
Absolutely, I'd recommend to use the latest 2.3.x branch release, which
is currently 2.3.11.

> Does the fact that it uses NIO make it any different since my
> application is only using the db?
It makes difference in a sense, that we don't have to have thread per
HTTP connection, but rather limited pool of threads to process incoming
requests.

> Maybe I can have grizzly also serve the static content instead of
> using apache too.
Sure, it's also possible with StaticHttpHandler.

If you have more specific questions - we'll try to help with them.

Thanks.

WBR,
Alexey.