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 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角