php - two servers access the same database -


i'm creating web application contains 2 servers, php , node. php server handle api calls , node server handle socket. and, both of these servers need read , write database -- mysql. wonder if it's idea have these servers access database directly? or, should make service in middle , have these 2 servers talk service when need access database. other suggestions welcome.

generally, second approach right way go; if querying same mysql database same application stack, create service layer handles task. can manage of connection details , modeling in 1 place. ease of maintenance improve quality of life, , subsequent app developers praise name.

this application design approach recommended, if future requirements have connecting number of data sources. want maintain sort of thing in 1 place, as possible. not mean, however, entire service layer should reside in 1 place. composite service pretty normal; various services can reside in different stack elements, , api routing utility, umbrella (http://apiumbrella.io/) can handle of client service requests, requests can location-agnostic. given that, similar service tasks, db transactions, should handled in 1 place reasons stated: make life easier not duplicating effort.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -