OK, I ran a test using the small CLI app "siege".  I don't know how reliable this test is but the results logged are *definitely* impressive...to say the least...not at all what I expected given what I've done.  This setup is as ghetto as it gets.

Here's my app:

Presentation: Wicket 1.1.1
Application: EJB3 on JBoss 4.0.4RC1 (non-clustered)
Database: MSSQL 2000 (Developer Edition)

The app is on my dev machine (my laptop) which is a single proc 2GHz Dell Latitude w/ 2GB ram.

I'm simply calling a collection of Entity beans from a stateless session bean and looping them in a table in Wicket.  There's maybe 20 records in the table.

Here's my Wicket code (without detachable model):
---------------------------------------------------------------------------------------------

public class Home extends WebPage
{
    public Home()
    {
        List<Product> products = this.getAllProducts();
       
        add(new ListView("products", products)
        {
            protected void populateItem(ListItem item)
            {
                Product product = (Product)item.getModelObject();
                item.add(new Label("description", product.getDescription ()));
            }
        });
    }
   
    private List<Product> getAllProducts()
    {       
        Products p = null;

        try
        {
            InitialContext ctx = new InitialContext();
            p = (Products)ctx.lookup("MyEarProject/ProductsBean/local");        
        }
        catch (NamingException exp)
        {
            exp.printStackTrace();
        }

        return p.getAll();
    }
}

Here's the same code *with* detachable model (ctor only):
---------------------------------------------------------------------------------------------
    public Home()
    {
        add(new HeaderPanel("headerPanel"));
        add(new FooterPanel("footerPanel"));
              
        IModel loadingModel = new LoadableDetachableModel()
        {
            Products p = null;
            protected Object load()
            {
                try
                {
                    InitialContext ctx = new InitialContext();
                    p = (Products)ctx.lookup("MyEarProject/ProductsBean/local");       
                }
                catch (NamingException exp)
                {
                    exp.printStackTrace();
                }
   
                return p.getAll();
            }
        };
       
        add(new ListView("products", loadingModel)
        {
            protected void populateItem(ListItem item)
            {
                Product product = (Product)item.getModelObject();
                item.add(new Label("description", product.getDescription()));
            }
        });
    }

Here are the results without detachable model:
---------------------------------------------------------------------------------------------
Transactions:                   5006 hits
Availability:                 100.00 %
Elapsed time:                  99.61 secs
Data transferred:           22311742 bytes
Response time:                  1.46 secs
Transaction rate:              50.26 trans/sec
Throughput:                223990.98 bytes/sec
Concurrency:                   73.32
Successful transactions:        5067
Failed transactions:               0
Longest transaction:            7.27
Shortest transaction:           0.02

...and with detachable model:
---------------------------------------------------------------------------------------------
Transactions:                   5388 hits
Availability:                 100.00 %
Elapsed time:                  99.56 secs
Data transferred:           24014316 bytes
Response time:                  1.32 secs
Transaction rate:              54.12 trans/sec
Throughput:                241204.47 bytes/sec
Concurrency:                   71.47
Successful transactions:        5448
Failed transactions:               0
Longest transaction:            7.08
Shortest transaction:           0.35

Now, the real question is; shouldn't I have seen serious performance/scalability degredation by *not* detaching the objects?  Really all we're talking about here are abstracted Hibernate sessions (JBoss EJB 3). It's probably safe to say that this would be a more dramatic difference w/ larger, more complex objects, correct?

I know these tests are rough and in no way "professional" benchmarks...but it's interesting nonetheless.  It appears that I could get away w/ *not* using detached objects on this project (and cleaner code)...since we never anticipate 100 *concurrent* users....but even if we did...the app would probably still be highly available.  Also, in production, All services won't be on the same machine...it'll likely start out on a dual-proc ( 2.8GHz xeon) app/web server w/ about the same amt. of ram and a separate database server w/ MSSQL 2K Enterprise (not my first choice in DB but I *have* no choice.)  Obviously, we could easily scale up later by both throwing more hardware at it by clustering it and adding detachable models around the session beans, if it became necessary.

Any thoughts?

-v

Reply via email to