Using node with MySql OR using node with PHP (which will handle the MySql operations) -


i have node.js server serves interactive html page client browser. in case, client frontend page not served apache server served node.js server.

when user perform actions (i.e. create wall post or comment), thinking of using 1 of possible flow of operations manage them, have no idea 1 better (in term of performance, scalability large amount of users, , ease of implementation). these options:

option 1:

  • socket.io send message details node server (which listens particular port). message encoded json.
  • node receives message.
  • node communicate directly mysql database. input sanitization performed @ step.
  • node broadcast details other users subscribed within same socket.io room.

option 2:

  • socket.io send details node server. message encoded json.
  • node receives message.
  • node calls php using http post. php controller handle http post message , save corresponding details mysql databsase. input sanitization performed @ step.
  • php notify node.js server via redis, let's using channel called "mysqldb".
  • node subscribe "mysqldb" channel, , broadcast corresponding details users subscribed within same socket.io room.

can advise me advantage , disadvantages of above 2 approach? there better approach?

counter questions:

  • how many steps required same action in each of options until through?
  • think things go wrong / fail / break each of options?
  • how easier if written in 1 language?
  • how time saved if data not passed arround between node, php, mysql , redis?
  • how many software packages have install , configure each of options?

unless have very specific reason plug php functional software stack , not know why question asked.

short version: option 1


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -