php - JSON Flat file vs DB querying -
i'm working on site has store locator built in.
since have similar sites developed in past, have experienced troubles when had search peaks hitting database (mysql) hard. these past location search engines querying database results.
now have taken different approach, since i'm not 100% sure, thought asking great community make me feel more secure direction or stick did before.
so new search, instead of hitting database requests, i'm serving search json file regenerates (querying database) when updated, created or deleted on locations list.
my doubt is, can high load of requests on json file have same effect high load of query requests on database?
serving search results json lower impact on db (and server resources) approach or it's not idea?
maybe out there had take same decision , can share experience me, or maybe know how things , recommend me approach.
flat files poor man's db , can more problematic heavily pounded database. example reading , writing file still requires lock, , not scale, same file may not accessible app servers.
my suggestion 1 of following:
benchmark current hardware, identify bottlenecks, scale out or accordingly.
implement caching layer, save on costly queries readonly data.
consider more high performant storage solutions such aerospike or redis
implement real full text search engine such elasticsearch or solr.
response comment #1:
you accomplish same thing without having read/write flat file (which must accessible app servers), caching data. here's quick n dirty rundown of how it:
zip + 10 miles:
query database, pull store data, json_encode, cache using key construct 92562_10, store in cache. when other users enter 92562 + 10 pull data cache vs database (or flat file).
city, state + 50 miles:
same above, except key construct may murrieta_ca_50.
but caching layer better performance, , cache server available app servers, easier having install/configure nfs share file on network.
Comments
Post a Comment