1

I currently have a server built using Netty/MySQL which I'm in the process of optimizing. It's incredibly simple, essentially does the following:

  • Accepts persistent connections
  • Makes database queries on behalf of the client (depending on client message and authorization)
  • Updates state of client (right now with local variables per client/channel- i.e. "numberOfQueriesMadeForThisClientSession")
  • Forces disconnects based on database, authentication and knowledge of other clients (i.e. if clientA is connected and clientB sends a special command, if verified by server, clientA is disconnected)
  • Reacts to disconnects (updates database, etc.)
  • Checks aes-encrypted content

However, I'm a little worried about the type of things that can happen with scaling... for example maybe handling timeout disconnects gracefully rather than user actually quiting or forced disconnects, race conditions, etc. etc.

Odds are pubnub has thought about this stuff with more tests than myself... so I'm wondering- what would be the basic structure to migrate my netty/mysql server to use pubnub? At a glance, it seems to me like pubnub is a pure message relay without any database or business logic processing...?

Language of choice is PHP but at this point I'm most interested in the basic architecture

davidkomer
  • 3,020
  • 2
  • 23
  • 58

1 Answers1

0

OK- now that I've given it some thought, I think it is totally doable for my specific use case, but Pubnub is not really designed to use (or require) additional persistent servers.

By using unique channel names and withholding subscribe/publish keys, different approaches can be taken, and it just isn't the same way as traditional server models.

It can also be accomplished by having a "super client" subscribe/process/publish, but in my opinion that kinda brings the thing back to square one.

My advice to myself and others- think of pubnub (and similar services) in a completely different way and try to avoid using a persistent "super client"/server at all if possible :)

davidkomer
  • 3,020
  • 2
  • 23
  • 58
  • We do have customers that have successfully persisted all the messages sent over PubNub into their own database. We are also working on making *fan-in* (many to 1) a lot simpler to accomplish. Some tips in here might be helpful: http://stackoverflow.com/questions/19823483/pubnub-or-pusher-and-storing-data-on-my-own-server – Craig Conover Sep 04 '15 at 15:52
  • Reconsider your PubNub assessment when [PubNub BLOCKS is released 2016 Q4](https://www.pubnub.com/products/blocks/). I am certain it will make your solution easy to implement, very robust and very scalable. – Craig Conover Aug 08 '16 at 16:19