We just finished the first phase of our project. We built a basic financial trading system. It uses JMS to communicate between rich Swing clients and an
EJB backend. The software looks good, but I'm a little concerned aout its performance
We don't implement encryption (it's fake money in a classroom, so we're not worried about hackers), so that saves us some expensive processing. We also aren't totally concerned with crashes. We'll have the holdings in the database, and if the last transaction didn't quite work (e.g. maybe during a failure, someone bought stocks but never paid for them, eh, we don't care). the bulk of the processing is simply handling and crossing orders. Everytime we get an order, here's what we do:
1) Get all holdings of the user, and mupltiple the quantity x current value per share x margin ratio (it's clightly more complicated then this, but this is a reasonable approximation).
2) Do the same as in step 1, but for outstanding limit orders.
3) If the numbers pass some check, we let the order go through (otherwise we jump to step 7, with a "not allowed" message)
4) We get the set of limit orders, cross the incoming order with them.
5) We update all holdings in the database.
6) Send an announcement about the cross to all users.
7) Send updates to each user involved in the transaction.
8) Recalc the margin for the order placer (steps 1 & 2), based on their new holdings and limit orders.
We take orders both from users and from computers traders who run in a background
thread on the server and place orders based on a formula.
We're running BEA Weblogic 8 on Win2000 on a 2.4GHz, 1G RAM machine. The database is Oracle 9i (I forget the specs, but its a slightly better machine).
Unfortunately, this is running far slower then we need.
We used to keep all limit orders in the database, because that took care of the locking for us. It was too slow. We now copy the limit orders to memory, maniuplate them during the order crossing, and then write them back to the database if they are new or changed (as opposed to reading each limit order as needed).
I recognize that step 8 duplicates work, and can spend some time speeding it up, but after looking at the profiler, that's not a huge performance impact. According to OptimizeIt, about 60% of the time is spent in WebLogic classes. It doesn't give me any more detailed information.
I can't believe that WebLogic classes are really using that much time. Does this include complied bean classes that are my code, but automatically generated? Any way to get more detailed information?
Roughly speaking, how much overhead do EJBs produce? My gut feeling (yes, I know, dangerous when looking at performance) is that the calculations aren't killing us; that's not to say they aren't significant, just that something else is sucking up time, but I can't see it in detail.
Does anyone have experience with JMS-driven EJB systems? Anyone have experience with financial applications like this? Or any systems which seem similar? I'd like to hear some rough numbers in terms of application support and load factors and machines used, and such. Heck, most anything will be helpful, as I'm feeling kinda in the dark here.
Thanks for reading all this!
--Mark