How many objects can be created simultaneously?
I have an ASP page including the following line:
Set objSMSReceiver = Server.CreateObject("SMSReceiver.clsMessageHandler")
where the component to be created is a VB DLL that I've developed. Usually this works. However the processing carried out by the VB DLL object takes 10-20 seconds, and when many clients simultaneously request this page I occasionally get the error: Object Required (which I capture by writing to a error log).
I assume this is because windows/IIS can only instantiate a certain number of these components? Is this likely to be the problem? How can I confirm? How can I investigate/resolve/improve this?
thanks
Kester
Re: How many objects can be created simultaneously?
There are numerous factors involved. What code actually raises the error?
You need to know what exactly is being done when this error occurs.
Re: How many objects can be created simultaneously?
The line I've included is the one that raises the error!
Re: How many objects can be created simultaneously?
Quote:
Originally Posted by kester_holmes
The line I've included is the one that raises the error!
Lets assume you are correct and that attempting to create the object is causing this error.
This implies that the Server.CreateObject call is somehow returning something other than an object, which doesn't seem likely, or is failing outright, which would not result in the error you are getting.
Typically, the Object Required error occurs when you attempt to "Set" a variable to something other than an object, or try to use a method on something that isn't an object.
Perhaps you can provide more informtaion about what is actually happening.
Re: How many objects can be created simultaneously?
OK I appreciate your help. Now the line that is causing the problem is trying to set an object:
Set objSMSReceiver = ...
I dont think the rest of the page is particularly relevant - 9 times out of 10 this works. I suspect that when this page is called simultaneously, or at very close intervals, the dll is still processing stuff, and only a limited number (or even 1) instance of this may be created at one time.
I'm sorry if I'm not being very clear but I really odnt know how to explain better. I really need to try and understand if this is the case or not and how to improve matters.
Is this anything to do with 'threading'?
Re: How many objects can be created simultaneously?
Quote:
Originally Posted by kester_holmes
OK I appreciate your help. Now the line that is causing the problem is trying to set an object:
Set objSMSReceiver = ...
I dont think the rest of the page is particularly relevant - 9 times out of 10 this works. I suspect that when this page is called simultaneously, or at very close intervals, the dll is still processing stuff, and only a limited number (or even 1) instance of this may be created at one time.
I'm sorry if I'm not being very clear but I really odnt know how to explain better. I really need to try and understand if this is the case or not and how to improve matters.
Is this anything to do with 'threading'?
Okay - lets see if we can figure this out.
Questions:
1: what is the instancing property of your clsMessageHandler set to?
2: Are you running your code in a COM+ package? and if not, why not?
3: Are you doing anything in the clsMessageHandler Class_Initialize event?
4: Are there any resources used in clsMessageHandler methods that are not being properly closed or discarded after use?
5: How many concurrent users need to be hitting the page before the problem shows up?
6: As you intimated, what is the threading model selected in the project properties > general tab?
Re: How many objects can be created simultaneously?
Excellent! i suspect these are exatly the type of things (about which i have no experiance!) that I need to consider.
1. Instancing is set to 5 - Multiuse
2. no idea what COM+ is. Should I be using this? What would I need installed on server to use this?
3. Yes I am doing stuff in the Initialise event:
'Initialise database connection
Set noDB = New clsDatabase
In turn clsDatabase.Initialize attempts to open a connection to the remote database for subsequent database transactions
4. Its possible that resources are not being discarded. By this you just mean ensureing that all objects are set = Nothing, right? I will check.
5. No idea how many concuirrent. Impossible to count and also to know whether the dll is still running. Probably no more than 10-ish. I log each request to the page and sometimes get up to 10 in the same 1-2 seconds (as I said the dll can take 20-30 secs to complete)
6. Single threaded
thanks for these suggestions,
it is likely that the load on server will increase dramatically soon so this will become urgent!
Re: How many objects can be created simultaneously?
Quote:
Originally Posted by kester_holmes
Excellent! i suspect these are exatly the type of things (about which i have no experiance!) that I need to consider.
1. Instancing is set to 5 - Multiuse
Multiuse is the "default" when you create a class in a dll. And it is probably the right choice for your project
Quote:
Originally Posted by kester_holmes
2. no idea what COM+ is. Should I be using this? What would I need installed on server to use this?
You need to read up on this. It is very likely that when you start scaling your site up for more users you are going to want your code to be running in COM+. What server are you using? The COM+ environment already exsists on your server, and you will work with it via the Administrative Tools > Component Services snap-in. We can go into this later as we delve into this - this is a big subject and is complex.
Quote:
Originally Posted by kester_holmes
3. Yes I am doing stuff in the Initialise event:
'Initialise database connection
Set noDB = New clsDatabase
In turn clsDatabase.Initialize attempts to open a connection to the remote database for subsequent database transactions?
This is what I was suspecting - I suggest you add some error handling code in here to see if this is where the error is accually occuring. Do you have a comprehensive error handling methodology in place? If not, that is also something you need to work on right away. It is possible your db connections are used up, and tons of other things as well. It would be very useful for you to determine if there are actually problems happening in here. Like I mentioned earlier, the error you are getting is caused in a few, specific ways, and the line of code you indicated in your first post does not seem likely to directly cause the error. Of course, I could be wrong and it wouldn't be the first time. Also... Is clsDatabase in the same dll as clsMessageHandler
Quote:
Originally Posted by kester_holmes
4. Its possible that resources are not being discarded. By this you just mean ensureing that all objects are set = Nothing, right? I will check.?
Yes, all objects ESPECAILLY DB CONNECTIONS and file resources have to be handled well. However, this is more than just setting to nothing - it is also properly closing connections and files, for example. You see, any resource that isn't being directly managed by your code is outside of the context of your running code - and therefore you need to instruct it to "dispose" of itself at the proper time - otherwise it just hangs out there, and you get "memory leaks" and out of resources type errors. You also need to pay attention to how you dispose of these things when errors occur - you can't just leave the code with the error without first determining the state of these "outside" resources and properly dealing with them
Quote:
Originally Posted by kester_holmes
5. No idea how many concuirrent. Impossible to count and also to know whether the dll is still running. Probably no more than 10-ish. I log each request to the page and sometimes get up to 10 in the same 1-2 seconds (as I said the dll can take 20-30 secs to complete)?
So one BIG question - 20 to 30 seconds? That is a very long time to do part of the processing for a page hit. Besides everything else, it will probably become very important to optimize this or you may never be able to scale.
Quote:
Originally Posted by kester_holmes
6. Single threaded?
Ah. This could be a problem. I would experiment making this apartment threaded. Is there a reason you specifically chose single threaded?
Quote:
Originally Posted by kester_holmes
thanks for these suggestions,
it is likely that the load on server will increase dramatically soon so this will become urgent!
You'll want to buy some books so you have them on hand when time gets tight. Stuff on COM+, IIS use of COM+, etc. These will be very cheap becuase you can buy them used at all the typical used book sites, and almost NOBODY is developing new stuff in ASP, VB6, and COM anymore.
Last but not least... any reason this can't be moved into something fresher such as .NET?
Re: How many objects can be created simultaneously?
i started to compose a large reply but then it crashed and I lost it all!
suffice to say I'm looking into some of the things you suggested. All your advice is MUCH appreciated.
Obviuosly .NET would be better but I'm the only developer at a start up company and have never used it. Training and upgrading would all take more time than we have at present unfortunately.
Ta
Kester
Re: How many objects can be created simultaneously?
Quote:
Originally Posted by kester_holmes
i started to compose a large reply but then it crashed and I lost it all!
suffice to say I'm looking into some of the things you suggested. All your advice is MUCH appreciated.
Obviuosly .NET would be better but I'm the only developer at a start up company and have never used it. Training and upgrading would all take more time than we have at present unfortunately.
Ta
Kester
I have gotten into the habit of composing my larger posts in notepad to keep from losing work, especially since I only dedicate about 15 min. a day to the forums.
I am happy to help. I often turn to others for help and don't think I would be one tenth as productive as I am if it wasn't for the bulletin boards, mailing lists, and forums.
As far as moving to .NET - the reason I mention it is because ASP.NET does away with all the problems of using COM components in an ASP site. The performance issues are much easier to deal with, as well as numerous other typical ASP limitations. However, I do understand that the learning curve could be too much in a situation like yours.
Let me know if I can be of further assistance.
Re: How many objects can be created simultaneously?
i am sure you can be of further assistance once I've found a little bit more time to investigate the code (finding time for development in amongnt the other project management, management reporting and customer problems is sometimes difficult :)!
As the only developer here your support is very welcome
have a good weekend
Kester
Re: How many objects can be created simultaneously?
I am now getting another, probably related, problem. Rather than throwing an error, I get data which is logged to file by my receving ASP page and then not processed(inserted) by my dll; but now error is thrown! I need to try and pin down where the error is occurring.
I dont suppose anyone could help me? I'm afraid it would probably mean me emailing you the code, as this would ne easier than trying to explain it all!