How to build an image web server?

后端 未结 4 515
青春惊慌失措
青春惊慌失措 2021-02-07 22:42

I am trying to build an web image server. It serves images to lots of clients(10 thousands+) simultaneously. (It will be a easier problem if there is fewer clients.) What is a g

相关标签:
4条回答
  • 2021-02-07 22:55

    How are the images to be served? Are the images generated on the fly? or are they static and stored as .jpg or other format on the file system?

    Either way, I'd use ASP.NET .ashx (generic handlers) and use the System.Drawing classes.

    You'll also want to setup TCP/IP Network Load Balancing per http://support.microsoft.com/kb/323431

    0 讨论(0)
  • 2021-02-07 23:13

    Definitely look around for a good delivery service. Akamai is the best known.

    if you really want to do it on your own, forget about Apache/IIS. much more appropriate are 'light' webservers. Two very good are lighthttp and NginX (wiki). NginX in particular, has a really solid performance.

    Edit: Content Distribution Networks (CDNs) have flourished in the last few years, and it's much easier to find easier and cheaper ones. In particular, it's quite simple to put your static content in Amazon's S3 and use CloudFront.

    0 讨论(0)
  • 2021-02-07 23:14

    With that many clients, you may want to look into using a content delivery network (such as Akamai). On the surface it might seem expensive, but if you really look at the cost of maintaining the hardware and particularly the cost of bandwidth, it starts to make economic sense.

    0 讨论(0)
  • 2021-02-07 23:17

    If you want to design the fastest static file webserver with lowest latency, here's how I would do it.

    1. Use an event loop to detect which sockets are ready
    2. Put those sockets in a queue
    3. Create a stack of threads to deal with sockets (1 for each core). When they finish, put them back on the stack.
    4. Assign work to threads.
    5. Cache all image files in memory.

    This is essentially what IO completion ports are minus the caching of files. This model is available in Windows and Solaris.

    http://technet.microsoft.com/en-us/sysinternals/bb963891.aspx


    (source: microsoft.com)

    0 讨论(0)
提交回复
热议问题