3 Replies Latest reply on Feb 26, 2003 9:57 AM by Adrian Brock

    Advice needed, please!

    tom Newbie

      Hi all:
      I'm currently in the process of deciding whether to use EJB or not for my new project. My web page uses JSP to generate dynamic web pages and it uses JavaBean to talk to a backend database server to issue all kinds of SQL statements such as select/insert/update etc.. I feel this kind of design (without using any EJB) will serve the purpose. However, the potential users of the Web page are huge. I'm concerned about the "scalability" problem. My questions are:
      1) Will my web application run into trouble if the number of users increases to a certain point?

      2) Will I not have the same problem if I use EJB instead? If so, I can use a session bean instead of a JavaBean to issue the same set of SQL statements. However, I don't see much of a difference between the two approaches. For example, after I have instantiated a session bean in the JSP web page, I call methods defined in the remote interface to issuing all kinds of SQL queries/updates. The methods I call are exactly the same as those defined in the JavaBean. The only difference is that one is defined in a JavaBean while the other is defined in a session bean. So if I make this change and I can say "I am now using EJB", will that solve my problem of "scalability" if I have any? As I said above, I am very concerned about my web application running into trouble when the number of users increases to a certain point. Will the design without using EJB inherently be vulnerable to this trouble? Will the design using EJB (such as session bean) be immune to this trouble or at least be easier to deal with this trouble? Could someone please give some specific scenarios to help me understand the difference between the two?
      3) It is said that "EJB design is N-Tired and N-Tiers allow you to redistribute load more efficiently". In my case, how do I re-distribute the load if needed? I can put the database server on a different machine than the one running the EJB application server to distribute the load, but the same thing can be done with the JSP/JavaBean (with EJB) design, i.e., I can put the database server on a different machine than the one running the servlet engine such as TomCat. I know EJB has lots of advantages. But I may not need them in this project. The "scalability" problem is really what will determine whether I should "to EJB or not to EJB". Could someone please give me some advice? Thanks in advance!


        • 1. Re: Advice needed, please!
          Adrian Brock Master

          That's a long question, I'll try not to give a long
          answer. :-)

          Replacing a java bean with a stateless session bean to
          access the database won't help with scalability.
          You gain a pooled bean instance, but assuming
          you have a pooled database connection where is the
          You do get to configurable security and transactions.

          You need a cache to take load from the database.
          Entity beans are a natural cache. But they require
          analysis of your data.
          What can be cached, is the data read mostly?
          What needs to be isolated across the cluster, is the
          data as important as a bank balance?

          A simple way to scale is to load balance the
          web/ejb colocated. But the more isolation you have
          on the database the less this will help.
          You do have failover if a box crashes.
          State replication is a further consideration which
          can be costly, try to keep your design stateless.

          Ideally, with correct design and configuration, the
          constraining factor should be the throughput of the db.

          Note: The default configuration for JBoss CMP is
          pessimistic locking (even for reads) and caching only
          within a transaction. This gives no surprises, but it is
          hardly efficient in most use cases.


          • 2. Re: Advice needed, please!
            tom Newbie

            Thank you for your reply!
            My real questions, in short, are:
            1) Will switching from using JSP/JavaBean only to using EJB (say session bean) help me to solve any possible performance problem I may have when the number of Web users increases a lot in the future? If the answer is yes, I'll switch to EJB. If the answer is no, then I'll continue using only JSP and JavaBean. Could you please give me a yes or no answer? I know using EJB may have other advantages, but currently the only thing which concerns me is whether it will help me solve the "large-number-of-users" performance problem?

            2) According to your reply, it seems often the database server through put is the bottle neck? Is that right? If so, it seems switching to EJB will not help me. Am I right?
            Thanks again for any advice!


            • 3. Re: Advice needed, please!
              Adrian Brock Master

              Repeating what I said above.

              Using a session bean will not help reduce the load on
              the database, using entity beans effectively will.