Performance Settings

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Performance Settings

Alan Williamson
Okay, so what is the "accepted method" for tuning Grizzly.

There appears to be a lot of setXXX methods on the SelectorThread with
very little documentation on their cause'n'effect.

For example, these two guys, they seem to associated with the number of
worker threads that will be spawned at any one time.

     st.setMaxThreads( 30 );
     st.setMinSpareThreads( 10 );

Is there any sort of benchmark as to what is "acceptable" values here.
I notice anything above 50 and i am not getting any more throughput.


This guy, is he to do with the HTTP KeepAlive or the Socket keepalive
directive?

     st.setMaxKeepAliveRequests( 25 );

The compression methods, are they to do with GZIP at the Http layer?
Calling that will that automatically GZIP my outgoing content if the
client accepts?   Or do i need to manually handle all that?


other things:

  - Where i do i set the maximum number
    of connections I will accept

  - Cache sizes; what caches are these referring to
     setMaxSmallCacheSize() etc

Any other tips you can suggest?  Which methods should i be ignoring as
internal, and which are expected to be twiddled by us the dumb user? :)

thanks

--
Alan Williamson
  "a wiki -and- a blog" @ http://www.Blog-City.com/

  b: http://alan.blog-city.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Performance Settings

Jeanfrancois Arcand-2


Alan Williamson wrote:

> Okay, so what is the "accepted method" for tuning Grizzly.
>
> There appears to be a lot of setXXX methods on the SelectorThread with
> very little documentation on their cause'n'effect.
>
> For example, these two guys, they seem to associated with the number of
> worker threads that will be spawned at any one time.
>
>     st.setMaxThreads( 30 );
>     st.setMinSpareThreads( 10 );
>
> Is there any sort of benchmark as to what is "acceptable" values here. I
> notice anything above 50 and i am not getting any more throughput.

Righ. The usual performance benchmark I'm doing is 2000 http clients
serviced by only 5 threads. I would recommend you set maxThreads between
5 and 30, not more.


>
>
> This guy, is he to do with the HTTP KeepAlive or the Socket keepalive
> directive?
>
>     st.setMaxKeepAliveRequests( 25 );

It's the number of requests a connection can handle. By default, when
HTTP/1.1 (or 1.0 with the keep-alive header) is added, grizzly will
close the connection after 250 requests (the last request will contains
the connection: close header). I would leave it to 250 to avoid DoS.

>
> The compression methods, are they to do with GZIP at the Http layer?

Yes.

> Calling that will that automatically GZIP my outgoing content if the
> client accepts?  

Right. By default the following mime are supported:

"text/html", "text/xml", "text/plain"

You can add yours as well.

Or do i need to manually handle all that?

Nothing to configure by default. Grizzly will do it for you :-)

>
>
> other things:
>
>  - Where i do i set the maximum number
>    of connections I will accept

SelectorThread.setMaxQueueSizeInBytes() //Default is 4096


>
>  - Cache sizes; what caches are these referring to
>     setMaxSmallCacheSize() etc

This is the static file cache. I usually set that value to 1028 (smaller
file doesn't need to be cached). Do you want to use the static file
cache? This significantly improve performance for static resources.


>
> Any other tips you can suggest?  Which methods should i be ignoring as
> internal, and which are expected to be twiddled by us the dumb user? :)

I think the current defaults are the best. Give me a couple of hours and
I will post a list of method you should look at (doesn't necessarily
need to change them, but at least you know they exists.

A+

-- Jeanfrancois



>
> thanks
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Performance Settings

Alan Williamson
>> The compression methods, are they to do with GZIP at the Http layer?
>
> Yes.
>
>> Calling that will that automatically GZIP my outgoing content if the
>> client accepts?  
>
>> Right. By default the following mime are supported:
>
>> "text/html", "text/xml", "text/plain"
>
>> Nothing to configure by default. Grizzly will do it for you :-)

mmm, i hate to disagree, but if i telnet to Grizzly and ask it for content:


GET /c/2/f/23/index.rss HTTP/1.1
host: 127.0.0.1
Accept-Encoding: compress;q=0.5, gzip;q=1.0

HTTP/1.1 200 OK
Set-Cookie: MF2=utmcr1xaw84x; Max-Age="63072000"; Path="/"
Content-Type: text/xml;charset=utf8
Content-Length: 30737
Date: Tue, 27 Nov 2007 16:29:16 GMT


Is there anything i need to do with my Response object to make sure the
Gzip'ing actually happens.


>>  - Where i do i set the maximum number
>>    of connections I will accept
>
> SelectorThread.setMaxQueueSizeInBytes() //Default is 4096

is that 4096 connections?  (seems strange since the method sig is Bytes,
kinda threw me)

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Performance Settings

Oleksiy Stashok

>>> Nothing to configure by default. Grizzly will do it for you :-)
>
> mmm, i hate to disagree, but if i telnet to Grizzly and ask it for
> content:
>
>
> GET /c/2/f/23/index.rss HTTP/1.1
> host: 127.0.0.1
> Accept-Encoding: compress;q=0.5, gzip;q=1.0
>
> HTTP/1.1 200 OK
> Set-Cookie: MF2=utmcr1xaw84x; Max-Age="63072000"; Path="/"
> Content-Type: text/xml;charset=utf8
> Content-Length: 30737
> Date: Tue, 27 Nov 2007 16:29:16 GMT
>
>
> Is there anything i need to do with my Response object to make sure
> the Gzip'ing actually happens.
Pls. take a look here at Jeanfrancois'es blog [1]. Seems by default
compression is set to "off", so it needed to be switched "on".

WBR,
Alexey.

[1]
http://weblogs.java.net/blog/jfarcand/archive/2006/06/enabling_http_c_1.html

>
>
>>>  - Where i do i set the maximum number
>>>    of connections I will accept
>>
>> SelectorThread.setMaxQueueSizeInBytes() //Default is 4096
>
> is that 4096 connections?  (seems strange since the method sig is
> Bytes, kinda threw me)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Performance Settings

Alan Williamson
Oleksiy Stashok wrote:
> Pls. take a look here at Jeanfrancois'es blog [1]. Seems by default
> compression is set to "off", so it needed to be switched "on".
> [1]
> http://weblogs.java.net/blog/jfarcand/archive/2006/06/enabling_http_c_1.html 

Great thank you.  You are right, it is set to off out of the box.  I
added this, and GZip'ing did indeed burst into life.


     st.setCompression("on");
     st.setCompressionMinSize( 14000 );


Although, i can't seem to get a handle to how much data was sent to the
client when gziping.  I thought this maybe may tell me, but it prints 0
and -1 respectfully.


public void afterService(Request arg0, Response res) throws Exception {
  System.out.println(
     "afterService: getBytesWritten=" + res.getBytesWritten() +
     "; getContentLength=" + res.getContentLength() );
}


I want to log how much data we are saving by GZIP'ing and the percentage
of clients that actually received GZIP content.  Very useful data this.

Any advice gratefully received.  I am loving this Grizzly so far, and
while the documentation in the JavaDocs is thin on the ground, i am
discovering that Jeanfrancois blog is the place to be!

thanks

a

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Performance Settings

Jeanfrancois Arcand-2


Alan Williamson wrote:

> Oleksiy Stashok wrote:
>> Pls. take a look here at Jeanfrancois'es blog [1]. Seems by default
>> compression is set to "off", so it needed to be switched "on".
>> [1]
>> http://weblogs.java.net/blog/jfarcand/archive/2006/06/enabling_http_c_1.html 
>
>
> Great thank you.  You are right, it is set to off out of the box.  I
> added this, and GZip'ing did indeed burst into life.
>
>
>     st.setCompression("on");
>     st.setCompressionMinSize( 14000 );

Indeed :-)

>
>
> Although, i can't seem to get a handle to how much data was sent to the
> client when gziping.  I thought this maybe may tell me, but it prints 0
> and -1 respectfully.
>
>
> public void afterService(Request arg0, Response res) throws Exception {
>  System.out.println(
>     "afterService: getBytesWritten=" + res.getBytesWritten() +
>     "; getContentLength=" + res.getContentLength() );
> }
>
>
> I want to log how much data we are saving by GZIP'ing and the percentage
> of clients that actually received GZIP content.  Very useful data this.

You can monitor a lot of data (but it reduce a little bit the
performance) by invoking:

st.enableMonitoring();

Grizzly will start collection a lot of information. You can grab the
statistic by doing:

st.getRequestGroupInfo().getXXX()

(the class is located under
grizzly-http/src/main/java/com/sun/grizzly/tcp/RequestGroupInfo.java

Let me know if that's not what you are looking at.

>
> Any advice gratefully received.  I am loving this Grizzly so far, and
> while the documentation in the JavaDocs is thin on the ground, i am
> discovering that Jeanfrancois blog is the place to be!

Keep the question coming! We all know the docs is lacking, but we are
working hard to improve it!

Thanks!

- Jeanfrancois



>
> thanks
>
> a
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Performance Settings

Alan Williamson
> (the class is located under
> grizzly-http/src/main/java/com/sun/grizzly/tcp/RequestGroupInfo.java
>
> Let me know if that's not what you are looking at.
>
>>
>> Any advice gratefully received.  I am loving this Grizzly so far, and
>> while the documentation in the JavaDocs is thin on the ground, i am
>> discovering that Jeanfrancois blog is the place to be!
>
> Keep the question coming! We all know the docs is lacking, but we are
> working hard to improve it!

Right that's it!  I HAVE FAILED!!!

I have failed to be tripped up by Grizzly; everything I have asked for,
is either already there, or can be added to by implementing the
corresponding interface.

Jeanfrancois you are a credit to the Java community; job well done sir.

Thank you for answering my questions so quickly and thoroughly.  You
probably haven't heard the last from me, but for the time being, i am a
very happy bunny!

thank you again,

a

--
Alan Williamson
  "a wiki -and- a blog" @ http://www.Blog-City.com/

  b: http://alan.blog-city.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]