使用 Azure 在哪里存储用户图片等内容?斑点存储?
我刚刚将我的一个测试用例项目迁移到微软的azure。
但对于类似于头像上传的功能,我需要对硬盘上的文件进行写访问。但这是云,所以这是不可能的。 我怎样才能构建这样的功能呢?我应该使用 Blob 存储还是有更好的解决方案?
将所有网站图像(fe 布局图像)存储在 Blob 存储中是否有意义?那么我会为我的静态内容拥有一个无 Cookie 的域吗?
I have just migrated a project of mine for test cases to Microsoft's azure.
But for functionalities similar to an avatar upload I need write access to the files on the harddrive. But this is a cloud, so this is not possible.
How can I build such functionalities instead? Should I use the Blob Storage or is there a better solution?
Does it make sense to store all website images (f.e. layout images) in the Blob Storage? So I would have a Cookie-free Domain for my static content?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Blob 存储绝对是放置头像等动态图像的地方。虽然您可以写入要运行的虚拟机上的磁盘,但您不能依赖它的存在 - 如果您的应用程序被移至另一台计算机(这可能由于多种原因而发生),则该存储将被删除。
您可以做的一件事是将图像存储在 blob 存储中,并将它们缓存在本地 VM 磁盘上(使用标准文件 IO 机制)。这样,您将获得相当好的性能,并节省一些存储事务,同时仍然确保您没有存储在易失性存储中。
如果您有完全静态的静态图像,这些图像将与您的应用程序捆绑在一起,并且可以像普通文件一样引用。但是,如果您需要更改它们,则需要重新部署应用程序 - 因此仅对不需要更改的图像使用此技术。
Blob storage is definitely the place to put dynamic images like avatars. While you can write to the disk on the VM you'll be running in, you can't rely on this to be present - if your app gets moved off to another machine (which could happen for any number of reasons) this storage will be erased.
One thing you could do is store your images in blob storage, and cache them on the local VM disk (using the standard file IO mechanisms). This way you'll get pretty good performance and will save on a few storage transactions while still making sure you're not storing in volatile storage.
If you've got static images which will be completely static, these are just bundled with your application and can be referenced like a normal file. But, if you will ever need to change them, you'd need to redeploy the application - so only use this technique for images which won't need to change.
请注意,Windows Azure 中有两种类型的 Blob:块 Blob 和页面斑点。块 Blob 适用于媒体文件服务,而页 Blob 针对其他工作模式进行了优化。
另请考虑使用 Azure 内容分发网络 (CDN) 来降低客户端的延迟。
Azure 还具有与 Silverlight Smooth Streaming 协同工作的流功能(如果感兴趣,请访问 http://blog.smarx.com/posts/smooth-streaming-with-windows-azure-blobs-and-cdn)。
Be aware there are two types of Blobs in Windows Azure: Block Blobs and Page Blobs. Block Blobs are appropriate for media file serving, whereas Page Blobs are optimized for other work patterns.
Also consider use of the Azure Content Distribution Network (CDN) for lowering latency to clients.
Azure also has streaming capabilities which work in concert with Silverlight Smooth Streaming (http://blog.smarx.com/posts/smooth-streaming-with-windows-azure-blobs-and-cdn if interested).
“将所有网站图像(fe 布局图像)存储在 Blob 存储中是否有意义?这样我就可以为我的静态内容提供一个无 Cookie 的域?”
是的,我想是的 - 这实际上是我现在正在推出的。
"Does it make sense to store all website images (f.e. layout images) in the Blob Storage? So I would have a Cookie-free Domain for my static content?"
Yes I think so - this is what I'm rolling out right now actually.