Skip to content

Commit d108fc3

Browse files
committed
add local+redis bench result
1 parent 434e9e2 commit d108fc3

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

README.md

+14-3
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,14 @@ How this benchmark run:
354354
5. Run coroutines in queue with N concurrent workers.
355355
6. Collect results.
356356

357+
Identifier:
358+
- Cacheme: Cacheme redis storage
359+
- Aiocahce: Aiocahce cached decorator
360+
- Cashews: Cashews cache decorate
361+
- Cacheme-2: Cacheme use cache chain [local, redis]
362+
- Aiocache-2: Aiocache cached_stampede decorator
363+
- Cashews-2: Cashews decorator with lock=True
364+
357365
Result:
358366
- Time: How long it takes to finish bench.
359367
- Redis GET: How many times Redis GET command are called, use this to evaluate pressure to remote cache server.
@@ -364,32 +372,35 @@ Result:
364372
| | Time | Redis GET | Load Hits |
365373
|------------|-------|------------|-----------|
366374
| Cacheme | 30 s | 166454 | 55579 |
375+
| Cacheme-2 | 18 s | 90681 | 55632 |
367376
| Aiocache | 46 s | 200000 | 56367 |
368377
| Aiocache-2 | 63 s | 256492 | 55417 |
369378
| Cashews | 51 s | 200000 | 56920 |
370-
| cashews-2 | 134 s | 200000 | 55450 |
379+
| Cashews-2 | 134 s | 200000 | 55450 |
371380

372381

373382
#### 10k concurrency
374383

375384
| | Time | Redis GET | Load Hits |
376385
|------------|-------|-----------|-----------|
377386
| Cacheme | 32 s | 123704 | 56736 |
387+
| Cacheme-2 | 20 s | 83750 | 56635 |
378388
| Aiocache | 67 s | 200000 | 62568 |
379389
| Aiocache-2 | 113 s | 263195 | 55507 |
380390
| Cashews | 68 s | 200000 | 66036 |
381-
| cashews-2 | 175 s | 200000 | 55709 |
391+
| Cashews-2 | 175 s | 200000 | 55709 |
382392

383393

384394
#### 100k concurrency
385395

386396
| | Time | Redis GET | Load Hits |
387397
|------------|-------|-----------|-----------|
388398
| Cacheme | 30 s | 60990 | 56782 |
399+
| Cacheme-2 | 27 s | 55762 | 55588 |
389400
| Aiocache | 80 s | 200000 | 125085 |
390401
| Aiocache-2 | 178 s | 326417 | 65598 |
391402
| Cashews | 88 s | 200000 | 87894 |
392-
| cashews-2 | 236 s | 200000 | 55647 |
403+
| Cashews-2 | 236 s | 200000 | 55647 |
393404

394405
### 20k concurrent batch requests
395406

benchmarks/trace.py

+32
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,36 @@ def callback(response):
188188
await client.close()
189189

190190

191+
async def bench_cacheme_zipf_with_local(gen: Callable[..., Iterable], workers: int):
192+
# reset node cache
193+
FooNode.Meta.caches = [
194+
Cache(storage="local", ttl=None),
195+
Cache(storage="redis", ttl=None),
196+
]
197+
redis_counter = 0
198+
await register_storage("redis", Storage(url="redis://localhost:6379"))
199+
await register_storage("local", Storage(url="local://tlfu", size=3000))
200+
client = cast(Redis, list_storages()["redis"]._storage.client)
201+
FooNode.load_count = 0
202+
203+
def callback(response):
204+
nonlocal redis_counter
205+
redis_counter += 1
206+
return response
207+
208+
client.set_response_callback("GET", callback)
209+
210+
queue = asyncio.Queue()
211+
for uid in gen():
212+
queue.put_nowait(simple_get(FooNode, uid))
213+
now = time.time()
214+
await run_concurrency(queue, workers)
215+
print(
216+
f"cacheme with local redis count {redis_counter}, load count {FooNode.load_count}, spent {time.time() - now}s"
217+
)
218+
await client.close()
219+
220+
191221
async def bench_cacheme_batch_zipf(workers: int):
192222
if workers > 10000:
193223
return
@@ -358,6 +388,8 @@ async def run():
358388

359389
print(f"==== zipf benchmark: concurrency {w} ====")
360390
await bench_cacheme_zipf(zipf_key_gen, w)
391+
r.flushall() # flush because local use same key
392+
await bench_cacheme_zipf_with_local(zipf_key_gen, w)
361393
await bench_aiocache_zipf(zipf_key_gen, w)
362394
await bench_aiocache_stampede_zipf(zipf_key_gen, w)
363395
await bench_cashews_zipf(zipf_key_gen, w)

0 commit comments

Comments
 (0)