doutou6803 2010-12-10 09:50
浏览 10
已采纳

缓存XML响应

We have this API to our ordering system in our Call-Center, that our online-ordering communicates with. But lots of the requests and responses are the same, more or less static - but the API server generates them, it don't just supply a static file.

What do you suggest as the best approach for caching XML responses? I have had a look at Zend_Cache. But from what i understand, i think it's client/session -based, i would like all clients to take advantage of the same cache.

Also every pageview does a pricerequest for the contents of the basket, what caching do you suggest for this. I think Zend_Cache maybe could come into play here !?

Basicly what i need, is to take the load of the API server, so it has more resources to hanlde price requests, and other requests that changes per request.

Update: 13. Dec. 2010 10.45

Request timing

2010-12-10T14:43:46+01:00 DEBUG (7): XML GET /ccstatus [0.054742097854614]
2010-12-10T14:43:46+01:00 DEBUG (7): XML GET /storestatus [0.063634157180786]
2010-12-10T14:43:46+01:00 DEBUG (7): XML GET /storestatus [0.062693119049072]
2010-12-10T14:43:46+01:00 DEBUG (7): XML GET /storestatus [0.062756061553955]
2010-12-10T14:43:46+01:00 DEBUG (7): XML GET /storestatus [0.062740087509155]
2010-12-10T14:43:46+01:00 DEBUG (7): XML GET /storelocations [0.065214872360229]
2010-12-10T14:43:46+01:00 DEBUG (7): XML GET /coupons [0.070861101150513]
2010-12-10T14:43:47+01:00 DEBUG (7): XML GET /packagedeals [0.51115489006042]
2010-12-10T14:43:47+01:00 DEBUG (7): XML POST /price [0.065691947937012]
2010-12-10T14:43:47+01:00 DEBUG (7): XML GET /pizzas [0.10685706138611]
2010-12-10T14:43:47+01:00 DEBUG (7): XML GET /bevtypes [0.059874057769775]
2010-12-10T14:43:47+01:00 DEBUG (7): XML GET /bevsizes [0.056848049163818]
2010-12-10T14:43:47+01:00 DEBUG (7): XML GET /items [0.070401191711426]
2010-12-10T14:43:47+01:00 DEBUG (7): XML GET /storestatus [0.062546014785767]
2010-12-10T14:43:47+01:00 DEBUG (7): XML GET /storestatus [0.063254117965698]
2010-12-10T14:43:47+01:00 DEBUG (7): XML GET /storestatus [0.062647104263306]
2010-12-10T14:43:47+01:00 DEBUG (7): XML GET /storestatus [0.062632083892822]
2010-12-10T14:43:47+01:00 DEBUG (7): XML GET /storestatus [0.062486886978149]
2010-12-10T14:43:47+01:00 DEBUG (7): XML GET /items [0.059072017669678]
2010-12-10T14:43:47+01:00 DEBUG (7): XML GET /storestatus [0.062618970870972]
2010-12-10T14:43:48+01:00 DEBUG (7): XML POST /price [0.063409805297852]

This is the requests for a single pageview, showing a page of side orders, and the basket contains 2 items.

Based on these times, do you think i will get a considerable difference by caching the data? These times is no-load-at-all, so at high-load the caching could probably come in handy.

  • 写回答

2条回答 默认 最新

  • duanbarong4617 2010-12-10 15:51
    关注

    I don't see an obvious way to do much caching on the pricerequest requests that are basket-dependent. These strike me as probably session-based, highly variable, so computing them per-request seems pretty necessary.

    The other requests - the "API requests" - if they truly are as static as you suggest, then they seem to be a great candidate for straight-up Zend_Cache with a File or Memcached backend. Just need to figure out an algorithm for generating a unique key for each of the static API requests you wish to cache.

    You could even specify an infinite lifetime in the frontend options and run a cron job to repopulate the cache on whatever frequency you think is reasonable enough to keep the content fresh.

    Just thinking out loud.

    Cheers!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c