[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 384
  • Last Modified:

ISAPI and NOT buffering output

I'm writing a Delphi ISPAI dll that uses several TPageProducers like :

Response.Content := MyPageProducer.Content

The problem is that the dll waits untill my entire Pageproducer finishes before sending anything to the browser, thus buffering ALL output.

Now MyPageProducer has some heavy queries in it and I want my application sending all available output while still processing the queries (thus NOT buffering the output)

Using ASP you can access some server settings to NOT buffer output, but I haven't found an equivalent in the TIsapiResponse and TISAPIRequest object.

Any ideas how i can send info to the browser while still processing the initial request?
0
gpeeraer
Asked:
gpeeraer
  • 3
  • 3
1 Solution
 
leon321Commented:
This is one of the common problems with CGI and ISAPI applications.

A http request initiates a CGI application to be executed or a function in a ISAPI dll to be called. The webserver simply waits until this has finished.

With ISAPI this means the called function has to return. After that, the webserver will examine the ISAPI return structure what has been filled by the called function (which includes the complete result you produced). The webserver will send the complete result to the client.

ASP, and other techniques, are closer integrated with the webserver and support the "streaming output" techniques you require. Streaming output with CGI or ISAPI dll's is simply not possible.

You should look for a way to split up the process at application level. May be you could split up the output and use hyperlinks to refer to different pages. Each hyperlink would be a separate request, and split up the total processing time.

Leon.
0
 
gpeeraerAuthor Commented:
But how is this possible for ASP (which is after all an ISAPI application) and not for a delphi dll?

Your suggestion is valuable, but it introduces a lot of programming complexity (first spin of some threads and answer with html+links, which are then called by the browser, these second calls have to wait for the end of the thread and the answer to the browser) while with not-buffered output I could work from within one thread.

Is it possible to pretend that a dll is an ASP-page? (Otherwise said, can I do delphi-programming for ASP?)

If there's no other way, then I have no other choice, but have to see whether it is worth the trouble.
0
 
leon321Commented:
I don't think the problem relies on the use of threads. You have a page that has to be produced and you probably won't gain any performance improvement by introducing multiple threads for 1 request.

I only said the most simple solution would be, to split up the page into different parts. For instance one main result page which includes 5 hyperlinks to other pages with subresults. This way your pageproduce time would be devided over the multiple pages/requests.
0
[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

 
gpeeraerAuthor Commented:
That's the problem. It's a all or nothing scheme so subresults are not available. Another solution is to provide extra frames, but this introduces the same problem, I have to wait till processing ends. The overload of one extra thread is in my situation not a real issue (intranet with limited amount of simultaneous users)

But thanks anyway.

Yesterday I tried a small example with a small browser-side javascript which every 100 msec checks if a .js file is entirely loaded. With the initial call, I spin off a thread to do the heavy processnig and respond with a page that says "wait please" and loads a .js file. This call waits untill the thread stops, then fills the js file and sends it back to the browser. if it is loaded entirely then I change the page dynamically.

The only remaining problem is the timeout of the browser when calling the js-file

I'll have to look on that too.
0
 
leon321Commented:
If you're browser is timing out over an intranet connection, you're total pageproduce time is indeed VERY long.

Are you sure you can't optimize the code which produces the result? For instance, with Delphi you have the benefit of using the BDE instead of ODBC, which drammaticly improves performance. If you are using ODBC or OLE DB, make sure you limit the amount of calls/queries. In general you get far better performance when you use a few advanced SQL queries, instead of allot of little queries.

Succes,
Leon.
0
 
gpeeraerAuthor Commented:
I haven't encountered a time-out for now, but the project i'm involved has about 25 decentral offices, connected through very slow connections. On other projects we had a lot of problems with that aspect, so i'm foreseeing more or less the timeout problem.

I already apply both suggestions (BDE and complex queries), But even those complex queries take 10-30 seconds to complete.

(I'll be out for more than a week, so i'll stop this thread)

Happy year ending,

Geert

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now