Slow Startup from Idle

Is it possible to stop the server from going to sleep when it is idle to improve responsiveness to new connections?
[116 byte] By [BobBerryman] at [2008-2-15]
# 1

Could you describe your problem it a bit more detail? Are you connecting to the express instance using "user instance=true" in the connection string?

Do logins seem to take longer if the instance is idle some particular amount of time?

JeromeHalmans at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 2

Yes, I am connecting using "user instance=true". Using E-Commerce Template on Server2003 Web Edition. Everything works brilliantly except when site has been idle for some time (10 mins at a guess) at which the database server seems to shut down.

The next time a user connects, it takes up to 30 seconds to respond, occasionally returning a timeout error.

EventID 17401 shows up in the logs, source: MSSQL$SQLEXPRESS

"Server resumed execution after being idle xx seconds: user activity awakened the server. This is an informational message only. No user action is required."

After that, it continues to perform very well responding immediately to new connections until the next time it goes to sleep.

BobBerryman at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 3

Hi Bob,

That's actually the expected behavior of User Instances. Check out the User Instance white paper for more details. In short, a user instance is a separate instance of SQL Express that is started up at runtime. As long as an application is connected to the User Instance, it runs as any other SQL service would. Once all connections have been shut down, the instance will hang around for a short time (about 10 minutes) and then shut down.

It sounds like you probably don't want User Instances, but I'll let you know ahead of time, that this will change some things about your application. If you stop using user instances, you may not want to use AttachDbFilename either, rather you'll want to attach the database to you main instance (probably <machine name>\SQLEXPRESS and then modify your connection string appropriatly to point at the database rather than attach it dynamically. Depending on what exactly you're doing you may need to modify or add some Login and User information to your server as well. User Instances have a special quality of running as the logged in user and giving them certain permissions, so they can access the database. When you move to the main instance, you have to setup security on your server.

Regards,

Mike Wachal
SQL Express team

MikeWachal-MSFT at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 4

Hi,

I had the same problem and tried solving it by stopping using User Instance mode and attaching the database to the server in the regular mode. AutoClose is disabled.

Although it doesn't enter "sleep mode" as often as it used to, I'm still receiving the 17401 event notice and it reponses slowly after being idle for some time.

Any advice?

IndyJames at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 5
Hello,
I'm also experiencing this same problem, with a number of servers. It doesn't sleep that often, but when it does it takes a long time to load up. I get messages like the following:
Server resumed execution after being idle 1360 seconds: user activity awakened the server. This is an informational message only. No user action is required.
I think the server may have been installed with "Enable User Instances" during setup.
The database in question was either detached/reattached or backed-up/restored from another server (not sure if this would make any difference)
Will User Instances need to be disabled at a server level? If so, how is that done? How am I able to tell whether user instances is enabled or disabled at the server level?
If anyone could help that'd be great.
Thanks,
Antonio
AntonioR at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 6

I have re-opened this discussion because it seems that what I had accepted as the answer hasnt cut it for some people.

It begs the question:

Under what circumstances would it be acceptable for the database server to take so long to respond?

I cant think of any.

If this behaviour is by design, then one would have to question the quality of the design.

BobBerryman at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 7

I don't think people are clear on the difference between User Instances and the main instance of SQL Express.

You will only get a User Instance if you are connecting to SQL Express using a specialized connection string that specifies two things:

  1. That a User Instance should be used.
  2. The path to the database file that should be attached when the application starts.

The connection string would look something like this:

Data Source=.\SQLEXPRESS; Integrated Security=True;AttachDbFilename=|DataDirectory|\myDatabase.mdf;User Instance=True

This connection string will cause an initial connection to the main instance (.\SQLEXPRESS) and then instruct the main instance to spawn a new instance of SQL Server under the user's context and attach the database specified to that new User Instance. The User Instance is a completely separate running instance of SQL Server form the main instance that is unique to the user and that will be shut down when there are no longer any connections to it.

This is totally different that attaching a database to the main instance, which stays running at all times, unless you've manually shut it down. If your question is about the main instance going into an Idle state, then your question is not unique to SQL Express and you should ask this question in the Database Engine forum. I believe all Editions of SQL Server have an Idle state and the other forum would be where you can find out how to affect that behavior.

The User Instance behavior is by design and it will not be changed for SQL 2005.

Regards,

Mike Wachal
SQL Express team

MikeWachal-MSFT at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 8
Would setting the 'user instance timeout' property to a higher value address this issue? So, as long as the user instance hasnt timed out, the Auto Close on the database will not happen, correct.

Also, how can this property be set at the database level (especially if using the VS IDE)? BOL shows how this property can be set at the server level using SSEUtil, but couldnt find about setting at db level.

One more question. Select * from sys.dm_os_child_instances does not return any rows for me. I am using SSEUtil. My application is currently accessing a user interface db & I thought this would list my user instance.

Dotnetter03 at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 9
I'm not using user instances (neither user instance= true or attachdbfile....) and i'm still getting the errors....

Server resumed execution after being idle 1792 seconds. Reason: timer event.

Server resumed execution after being idle 1406 seconds: user activity awakened the server. This is an informational message only. No user action is required.

Please help!?!

dioptre at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 10

The server being idle isn't an error, it's just a state of the server. It's not clear what problem you're trying to solve here, could you elaborate?

Mike

MikeWachal-MSFT at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 11

Is it possible to prevent the server from going idle?

(given that i'm not using user instances)

dioptre at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 12

Not for SQL Express.

You can control whether a database is closed automatcially or not using the 'Auto Close' property (Clever name that...) but the fact that SQL Express scales back it's working set after a period of idle time is not configurable.

If you're application demands high availability in terms of never going idle, you will need to purchase one of the higher Editions of SQL Server.

Mike

MikeWachal-MSFT at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 13
I've got the same problem. I'm going to make a stupid thread in my app that dumps stuff into a table periodically to keep SQL Express awake. I'll let you know how well it works.
GandalfHudlow at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...
# 14
Works like a charm.
GandalfHudlow at 2007-9-8 > top of Msdn Tech,SQL Server,SQL Server Express...

SQL Server

Site Classified