I am currently in the process of building a SQL database in Microsoft Azure for handling pictures, documents, etc. What is the most efficient/best way of storing data? Uploading the files directly to the DB, or by sourcing the files from something like Azure BLOB? I have read numerous posts about people uploading it directly to the DB, but I am concerned about its efficiency.
Thank you in advance for any replies.
You can store in something like Azure SQL DB for example but I would not recommend it, you should definitely store in Azure Storage (BLOB) and then for reference store in a DB. Azure has multiple relational and NoSQL data stores which are offered as platform services.
I would do two things, use a NoSQL platform data store like Cosmos DB using SQL Core API to store the metadata for the images, here you can use the filename as the partition ID to do a point read (this is very fast read and it would be a very cheap option with blazing fast performance) and secondly I would use Azure CDN to make sure images are accessed via CDN so that they are faster.
Azure CDN has three options; Akamai, Verizon and Microsoft. You can test which CDN is faster from where you are from here: https://cloudharmony.com/speedtest-for-azure
Using the above URL you can also use to test which Azure region is closer to you so to use that region, or test for your end-users and choose the region closer tot them.
I would say storing in Azure BLOBs is a better idea. Imagine you have 100 GB files stored in DB.
It will slow down your query if your table is not designed properly.
Backup & Restore DB will be very slow.
Azure DB is more expensive than Azure BLOB for the same size.
If your total file size is small enough, it doesn't make much difference.
Related
I am writing a new application at the moment and certain entities in the application have images (just used for display purposes on the website).
I want to host my application on azure later and I am trying to figure out whether it would be better to use Azure Blob storage to store all images or just store them in the DB?
What is better performance wise when loading the images on the website?
SQL: Controller -> DB -> VIEW
Azure Blob: Controller -> Webcall to Azure DB -> VIEW
Could someone please explain benefits of either solution to me so that I can make up my mind?
How you design your database storage scheme is subjective, but there are objective things to consider in your scenario. I'll address those, and leave the "which should I choose" to you...
Azure Storage blobs are designed for bulk "block" data (such as documents, images, etc). Something like SQL Database is designed for metadata (stuff you search/index/query).
Everything can be done via SQL Database, and you would only need to worry about SQL queries (and it sounds like that's something you're already familiar with). SQL Server (and SQL Database) have always had the ability to store binary content via its BLOB type.
While you can store your images in SQL Database, you will find that your database size increases considerably, vs just storing queryable metadata. And while SQL Database service allows you to scale your storage, you'll find larger scale in blob storage (up to 500TB) at a lower cost than SQL Database service. If you run SQL Server in a VM, then you'll still have storage cost (attached disks) equivalent to blobs, along with VM costs.
Storage blobs, by themselves, don't provide a query language - you will need to know the container and/or blob name. So, for optimum searching, you'll want a queryable database with your metadata (e.g. SQL Database).
If you store your images in blobs, and reference them via URI in your database, you will be able to query against your database, find the image's URI, and then read from blob storage appropriately.
Also note: With blobs, you'll be able to provide direct image URI access to, say, a browser or an app (even if the blob is marked as private), which allows you to then bypass your app tier when delivering binary (image) content to the end-user. Blobs may also be cached in the CDN, which you cannot do with SQL Database.
Which you choose is ultimately up to you; I simply provided the objective reasons to use each.
Much cheaper in BLOB.
You are also probably going the get faster transfer as BLOB. Now the initial lookup may be a little faster with SQL but for a large image I think BLOB would win. SQL is just plain not optimized for big stuff and BLOB is.
And you keep SQL free to serve up short stuff.
I have the following set up:
Azure service
Azure SQL database
Azure Table Storage
Azure Blob Storage
I am trying to develop a backup strategy for this service.
The thing is, that SQL, Tables and BLOBs should be synced. In the backup all three of those have to be of the same version. (backups taken at the same moment). And the main problem is - I can only afford several minutes downtime, not more than that.
What should I do? May be there is existing solution?
Windows Azure Storage supports geo-replication for Blobs, Tables and Queues. Data in the storage account is made durable by replicating transactions across different storage nodes in the same region (LRS) or a secondary region (GRS). GRS is the default redundancy option when creating a storage account. Refer to http://blogs.msdn.com/b/windowsazurestorage/archive/2013/12/11/introducing-read-access-geo-replicated-storage-ra-grs-for-windows-azure-storage.aspx for more details.
If you want to build a custom backup solution then you could use the techniques suggested in the below 2 blogs
1) http://blogs.msdn.com/b/windowsazurestorage/archive/2010/04/30/protecting-your-blobs-against-application-errors.aspx
2) http://blogs.msdn.com/b/windowsazurestorage/archive/2010/05/03/protecting-your-tables-against-application-errors.aspx
I am not sure of the exact use case of why you need to backup azure table and blob. You can backup All the above services without downtime; might be there would be slight glitch or bottleneck performance with SQL database durning back.
The single shot answer is to write a custom script which would read the data from azure table ( or SQL database, or the required service ) make a archive (packaging) and store it back.
The important thing to note here is where would storage backups, broadly speaking generally store the archives in blob. In this case you have thing where you would be storing, if you are storing on-premises you need calculate upon the storage locally, out bandwidth cost and latency of the data transfer from azure.
PS : cloud storage by itself has good leave of availability and durability, you further improve these factors by enabling geo-replication
I'm extremely confused, so I've created an SQL Database in Windows Azure, created a "video table" with a "video_file" column as "varbinary(max)" because I want to upload a video file into that field, however Azure offers no "Upload" option like say, PHPMyAdmin does where you can hit "browse" and upload a video directly into the field. Can anyone guide me as to how to actually upload a file into a Windows Azure SQL Database so it can be read as a varbinary type? Can it be done within the Azure management portal? Or does it require some sort of external program/service?
To answer your question, the functionality to upload files directly into SQL Azure Database does not exist. This is something you have to do on your own.
Can anyone guide me as to how to actually upload a file into a Windows
Azure SQL Database so it can be read as a varbinary type?
Do a search for uploading files in SQL Server and you will find plenty of examples on how to do that. Take a look at this link for example: http://www.codeproject.com/Articles/225446/Uploading-and-downloading-files-to-from-a-SQL-Serv
Can it be done within the Azure management portal? Or does it require some sort of external program/service?
No. This functionality does not exist in Azure Management Portal. As mentioned above, you would need to write some code to do so.
A little bit off-topic comment:
May I suggest that instead of saving the image files in the database you save them in Blob Storage and store the URL of the blob in your table. There're some advantages I could see in this:
Compared to SQL Database, Azure Blob Storage is much cheaper. If you store video files (or in other words large files) in the database, you will end up with large database and thus end up paying more money.
You will be choking the database when reading this large data from the database which will impact the performance of your application.
Whats the advantage/disadvantage between storing files as a byte array in a SQL table and using something like Amazon S3 to store them? Whats the advantage of S3 that makes it so I should use that instead of SQL?
Pros for storing files in the database:
transactional consistency
security (assuming you need it and that your database isn't wide open anyway)
Cons for storing files in the database:
much larger database files + backups (which can be costly if you are hosting on someone else's storage)
much more difficult to debug (you can't say "SELECT doc FROM table" in Management Studio and have Word pop up)
more difficult to present the documents to users (and allow them to upload) - instead of just presenting a link to a file on the file system, you must build an app that takes the file and stores it in the database, and pulls the file from the database to present it to the user.
typically, database file storage and I/O are charged at a much higher premium that flat file storage
Can anybody help me in understanding how to upload large files in SQL azure using block.
I am not able to find any good implementation of Blocks to upload files in SQL azure.
Thanks,
Ashwani
You may want to look at storing large files in Azure BLOB Storage. You will end up running out of size in your SQL Azure database, or put yourself into a more expensive SQL Azure price point, by storing files in your relational database. You can always store the pointer to your BLOB in your relational database.