340 likes | 652 Views
Data Persistence In A Web Hosted World. Jeff Ammons. The Atlanta Journal-Constitution Developer/DBA GGMUG.com President Gwinnett, Georgia, Microsoft User Group 2 nd Thursday, 6:30 PM Gwinnett Tech Blog: http://ammonsonline.com/jeffablog. Agenda. Define Hosted Environment
E N D
Jeff Ammons • The Atlanta Journal-Constitution • Developer/DBA • GGMUG.com • President • Gwinnett, Georgia, Microsoft User Group • 2nd Thursday, 6:30 PM Gwinnett Tech • Blog: http://ammonsonline.com/jeffablog
Agenda • Define Hosted Environment • Explore Data Persistence Options • DBA Tasks With Hosted SQL Server • Data Access With LINQ and Entity Framework
What Is Hosted Environment? • Web • Shared Server • Managed By Hosting Company
What’s Included? • Web Server • File Storage • Database • Bandwidth • Email
Examples • GoDaddy • Hostgator • DiscountASP.net • Bizhostnet.com
Who Is This Environment For? • Start-ups • Non-profit organizations • Personal use
Why Choose A Hosted Env? • Lost cost ($5-$20/month) • Quick Start • Fewer People Required • No hardware to buy • No hardware to maintain • No server room
Challenges • Server Access • Server Options • Server Load • Dude, Where’s My Data? • Dude, Who Can See My Data?
Microsoft vs FOSS:The FOSS Advantage • Lots of FOSS based sites (LAMP) • Lots of FOSS sample code • Zero start-up cost • MS stack seen as ugly and corporate-looking
Microsoft vs FOSS:The Empire Strikes Back • Asp.Net MVC • JQuery supported OFFICIALLY • Visual Studio Express Edition • BizSpark • WebsiteSpark • You CAN achieve zero start-up cost • You CAN make good looking sites
Asp.Net Options SharePoint WebForms MVC ASP.NET
Data Persistence Options • MySQL • SQL Server • File Based • XML • JSON
Why Not MySQL? • .Net naturally works better with SQL Server • LINQ To SQL works ONLY with SQL Server • Entity Framework support for MySQL is dodgy • This is NOT MySQL Saturday…
SQL Server • $15/month = Unlimited 200 MB DBs • Good basic set of functionality • Choice of access methods • LINQ To SQL • Entity Framework • ADO • Etc.
What’s Missing? Missing In Action Alternative • Agent • SSIS • SSRS • SSAS • Wish You Had Agent • Stored Procs • ASP App Perhaps With Silverlight, why not? • None
Types Of Access • Direct Access • SQL Server Management Studio • Expose YOUR database directly to the Internet • Web Admin • Primitive tools • CYDB
Typical DBA Tasks • Set Up • Schemas • Tables • Indexes • Views • Stored Procedures • Backups/Restores • Imports/Exports
Developer/DBA • Developers vs DBAs • Objects vs Relational Data • ORM
What Is LINQ? • Language INtegrated Query • SQL-like language construct for .Net • Joins • Tables • Objects • Both • Aggregation • Selection
Example LINQ Query var orderedModuleList = from module in itemList.getList() orderby module.Name select module;
LINQ To Lots Of Stuff • LINQ To Entities • LINQ To SQL • LINQ To Objects • LINQ To XML
File System Options • POCO (Built-in .Net Serialization) • XML
Why? Why? Why? • Not ALL apps need relational databases • Burn the heretic!!! • SMALL datasets • Lots of Readers/Few Publishers • Blog • Informational site • Personal site • Excessive DB Traffic
Example • Custom ASP.Net Membership Provider • Basic log-on info • Works great with 10-30,000 users • Total DOG with 500,000 users • No calls to DB server • Most start-ups would KILL to get 10,000 users
Goals For Your Project • Website itself • Web app others can use
Strategy 1: SQL Server • Your hosting plan gives you all the DBs you need • Latency of calling DB server is acceptable • Don’t kill yourself by calling DB too much • Cache, Cache, Cache
Strategy 2: File System Now, SQL Server Later • Repository Pattern • LINQ lets you query object collections • Switch to SQL Server if you grow • Not as big a deal as it once was • SQL Server now pretty cheap
Helpful Links • MSDN: Dynamic Management Views and Functions • http://msdn.microsoft.com/en-us/library/ms188754.aspx • SQLServerCentral • http://www.sqlservercentral.com/ • SQLBlog • http://sqlblog.com/
Helpful Queries • SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'), SERVERPROPERTY ('edition') • select top 100 *from sys.dm_tran_locks • select login_name, count(1)from sys.dm_exec_sessionsgroup by login_nameorder by count(1) desc • SELECT creation_time ,cursor_id ,name ,c.session_id ,login_name FROM sys.dm_exec_cursors(0) AS c JOIN sys.dm_exec_sessions AS s ON c.session_id = s.session_id WHERE DATEDIFF(mi, c.creation_time, GETDATE()) > 5;