How good and/or necessary are Stateful Web Services?

前端 未结 5 1113
感动是毒
感动是毒 2020-12-31 01:47

What kind of server do you people see in real projects?

1) Web Services MUST be stateless: Basically you must send username/password with every request, every reques

5条回答
  •  隐瞒了意图╮
    2020-12-31 02:29

    While it's only a small difference but it should still be mentioned:

    It's not state in web services that kill scalability, rather it's state on the App Server that's hosting the web services that will kill scalability. The moment you say that this user needs to access this server (as done in sticky sessions) you are effectively limiting your scalability options. The point you want to get to is that 'Any of your free load-balanced App servers' can handle this web service request and if I add 1 more App Server I should be able to handle % more users.

    It's totally fine (and personally recommended) if you want to maintain state to pass in an authentication token and on each request get the service to retrieve your 'state' from a data store (preferably a redundant and partitioned one, e.g. distributed+replicated key/value data store). That's how Amazon does it with SimpleDb and Google with BigTable.

    Ebay takes a slightly different approach and stores most of the clients state in a cookie so it gets passed in with every request. Although it generates a lot more traffic, it still scalable as any of their servers can still handle the request.

    If you want a scalable data store I would recommend looking at redis it has speed and features that can't be beat in a key/value data store.

    You should also check out highscalability.com if you want access to good material on how to build fast and scalable services.

提交回复
热议问题