Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why does VFP have a MTDLL?
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00980541
Message ID:
00982132
Views:
57
>Using the Sleep API (Sleep(0)) will free up the processor in a variety of situations and using SYS(3050) will make sure vfp doesn't hog too much memory especially for long-running process. For example, I use Sleep(0) and SYS(3050, 1, VAL(SYS (3050, 1, 0)) / 3) to make sure http uploads work smoothly in a vfp web app.

>I can't believe vfp is unique in this regard as far as accomodating long-running tasks on the web. ASP.NET may improve on it somewhat, but is basically the same thing...


All of things don't help if you're in the middle of a long SQL statement.

VFP is not unique, but VFP is very aggressive about CPU usage. SQL Server for example is smart enough to stay within an assigned amount of CPU usage regardless of how complex a query gets because it internally introduces wait states. Other environments are much more forgiving with CPU cycles.

DOEVENTS and Sleep(0) give up processor cycles only when you get a chance to do it in your code. Most of hte things that peg VFP aren't those but SQL Statemetns, reports etc.

+++ Rick ---

>>HI Anatoli,
>>
>>>If possible, could you describe what might happen to the web server when several users request such heavy-duty report rendered by VFP MTDLL+ASP application. What could be done to prevent/improve the situation on the server side?
>>
>>Well, what happens is this:
>>
>>You load a slow running report and ASP will fire up your COM component and run it on one of the ASP threads. CPU usage will jump as soon as VFP starts into the processing in earnest (long SQL statement etc. - any single commands that run for a long time and you can't break yourself with something like DOEVENTS). Reports too in some cases, but I think the biggest issue is SQL commands. VFP will eat up most of the available CPU.
>>
>>Now another request comes in (or the same person tries to do it again because he thinks the request failed) and now two requests with heavy processing are chewing at the CPU. Repeat with as many as you need... <g>
>>If you get enough requests going ASP is eventually going to deadlock as requests are taking to long that they time out and new requests are coming in to back up the incoming request queue.
>>
>>BTW, this scenario is not specific to ASP+COM - this can happen with anything using VFP as the backend even using the VFP OleDb driver.
>>
>>Scenarios around this:
>>
>>1. Make sure users cannot repeat a click. That's the most common problem if you one or two rare requests on your site. Disable the submit button or display a different part of the HTML page once prcessing starts so that the user cna't refresh or click again and fire more requests. Along the same lines its very important to make the user see that something's happening which can be as simple as displaying an animated Gif.
>>
>>
>>2. Use an external SQL engine. Offloading to SQL Server on another machine (or even the same machine) minimizes this sort of behavior. Offloading obviously releases the CPU load on the local machine and while the request now may tie up an ASP thread (which are limited) this is infinitely less destructive than eating up the CPU. Even if SQL Server is local you get some benefit because SQL Server will not completely take over the CPU as VFP does.
>>
>>
>>3. Use Asynchronous request processing and offload to a separate machine. This is usually the most reliable and recommended scenario. Instead of processing requests inline in your Web application code run the request in a queued fashion on another machine. This usually involves two things: Some sort of Queing mechanism (MSMQ or a custom queue implementation using tables) and a Process server that can read info out of the queue, process requests and stuff the result back into the queue. You can then either return the request to the user right then (while providing update information) or you can asynchronously provide it to the user by sending an email with the results etc. I wrote up an article many years ago about how to build a VFP based Aysnc Queue manager. It's a Web Connection article but it really applies and can be used with any Web backend using VFP. http://www.west-wind.com/presentations/wwAsyncWebRequest/wwAsyncWebRequest.htm
>>
>>
>>Note that the problem in these scenarios usually is not the length of time the request takes but hte amount of CPU that's being used. The CPU usage is the killer and in these scenarios it doesn't take much to bring an app to its knees.
>>
>>
>>Hope this helps,
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Reply
Map
View

Click here to load this message in the networking platform