加速多线程的Web应用程序

时间:2021-04-05 21:01:09

In a particular web application that I am working on, it needs to load a lot of data for a webpage. The page has 4 main sections. When a user goes to this page it needs to have all 4 sections populated.

在我正在处理的特定Web应用程序中,它需要为网页加载大量数据。该页面有4个主要部分。当用户转到此页面时,需要填充所有4个部分。

If I load each section sequentially then this is going to take awhile to load up the entire page. There are a lot of queries that will need to run to get the data. I was wondering if using threads for each section in the backing bean (UI bean) is a good idea here (essentially calling each method in the service bean in a thread). I know spawning off threads in a web application is usually considered risky. So I am looking for advices.

如果我按顺序加载每个部分,那么加载整个页面需要一段时间。需要运行许多查询来获取数据。我想知道在支持bean(UI bean)中为每个部分使用线程是否是一个好主意(实质上是在一个线程中调用服务bean中的每个方法)。我知道在Web应用程序中生成线程通常被认为是有风险的。所以我在寻找建议。

Some background info: the application is being developed in JSF 1.2 with weblogic as the container.

一些背景信息:应用程序正在JSF 1.2中开发,weblogic作为容器。

1 个解决方案

#1


0  

My answer is, it depends.

我的答案是,这取决于。

If all sections just query from same db its pointless. If you do some serious heavy calculations on something than you can consider threading.

如果所有部分只是从同一个数据库查询它毫无意义。如果你对某些事情进行了一些严肃的计算,那么你可以考虑使用线程。

#1


0  

My answer is, it depends.

我的答案是,这取决于。

If all sections just query from same db its pointless. If you do some serious heavy calculations on something than you can consider threading.

如果所有部分只是从同一个数据库查询它毫无意义。如果你对某些事情进行了一些严肃的计算,那么你可以考虑使用线程。