how to make two websites talk to each other?

199 views
Skip to first unread message

Nicolaas Thiemen Francken - Sunny Side Up

unread,
Jul 18, 2016, 8:54:25 PM7/18/16
to silverstripe-dev
Hi,

We are working on two sites that need to share some information (e.g. blacklisted emails for newsletter, risky transactions). What is the best way to achieve this?

Options I can see: 

(1) sites talk directly to each other - if so, would this be through a restful api or otherwise? Would we store all the data on site A with the site B basically reading and writing to site A OR would both sites have a full dataset with regular synchronisation (e.g. every ten minutes). 

(2) set up third database that both sites connect to - either directly or through a restful api or something like that. This seems like the cleanest option, so I would love some more defined ideas on how this could work.

(3) sites directly connect to each others' databases - this seems a bad idea in terms of security and speed (locked tables).

​I would very much appreciate some ideas around this.

Note: in our case, the sites actually share the same code base (but have separate databases, themes, assets, etc...) and they are running on the same server.  

Thank you​


--
Nicolaas 

Robbie Averill

unread,
Jul 18, 2016, 9:05:24 PM7/18/16
to SilverStripe Core Development, n...@sunnysideup.co.nz
Hi Nicolaas,

I'd definitely suggest exploring option #1 for the sake of decoupling your two websites. Option 2 and 3 may be a little faster to achieve, but option 1 is certainly the "best" approach IMO.

Cheers,
Robbie

Marcus Nyeholt

unread,
Jul 18, 2016, 9:12:27 PM7/18/16
to silverst...@googlegroups.com
Nicolaas, I use https://github.com/nyeholt/silverstripe-syncrotron for cross-system data sharing. It's only marginally above alpha level quality/stability wise, but I've used it in several systems where I've needed to have data going back-and-forth. 

--
You received this message because you are subscribed to the Google Groups "SilverStripe Core Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to silverstripe-d...@googlegroups.com.
To post to this group, send email to silverst...@googlegroups.com.
Visit this group at https://groups.google.com/group/silverstripe-dev.
For more options, visit https://groups.google.com/d/optout.

Nicolaas Thiemen Francken - Sunny Side Up

unread,
Jul 18, 2016, 9:13:00 PM7/18/16
to silverstripe-dev
Thank you for your response Robbie - what exactly do you mean with decoupling?   

Just to be clear - sites share the same code base, but they run independently (i.e. they have their own physical locations on the server and they may run their own git branches (or similar) in the future.


Nicolaas Thiemen Francken - Sunny Side Up

unread,
Jul 18, 2016, 9:17:41 PM7/18/16
to silverstripe-dev
Marcus, that looks great! I will have a go at using it.  Thank you.

Robbie Averill

unread,
Jul 18, 2016, 9:18:02 PM7/18/16
to SilverStripe Core Development, n...@sunnysideup.co.nz
Hey Nicolaas,

Decoupling web services means that you manage them separately, i.e. separate code, separate infrastructure, separate databases, etc etc. It's a good concept to adopt early on (in my opinion) because it means you can change A without it breaking B (necessarily).

In your case, if you introduced a shared database or connected to one of the sites databases from the other one you immediately introduce a "coupling". This could be avoided by option #1 in that if you implement a REST API between A and B, you could theoretically introduce C, D, and E in between A and B as long as the input/output from the API is the same... hope that makes sense.

Robbie

Colin Burns

unread,
Jul 18, 2016, 9:53:04 PM7/18/16
to silverstripe-dev
Hi Nicolaas,

Why about the multisite module. I use this and both sites utilize the same DB so it's just a single variable (site) you need to factor into calls etc.

Cheers,
Colin

Colin Burns
M: +1(250)899-1204 (Canada)
P: +61 7 3102 4334 (Australia)
E: ccb...@gmail.com

_____________________________
From: Nicolaas Thiemen Francken - Sunny Side Up <nfra...@gmail.com>
Sent: Monday, July 18, 2016 6:13 PM
Subject: Re: [silverstripe-dev] Re: how to make two websites talk to each other?
To: silverstripe-dev <silverst...@googlegroups.com>



Thank you for your response Robbie - what exactly do you mean with decoupling?   

Just to be clear - sites share the same code base, but they run independently (i.e. they have their own physical locations on the server and they may run their own git branches (or similar) in the future.


--

Nicolaas Thiemen Francken - Sunny Side Up

unread,
Jul 18, 2016, 11:25:24 PM7/18/16
to silverstripe-dev
On 19 July 2016 at 13:53, Colin Burns <ccb...@gmail.com> wrote:
Hi Nicolaas,

Why about the multisite module. I use this and both sites utilize the same DB so it's just a single variable (site) you need to factor into calls etc.



​Hi Colin,

Thank you for your reply.

This is a large e-com site and I guess I fear that:

(a) we always have to consider the multi-site dimension in every piece of code we write

(b) the database would be much bigger (slower?) and the code may also be a bit slower (as it has the multi-site code "woven in"). 

Would be interesting to benchmark it (if only we had time for that ;-)))





Nicolaas Thiemen Francken - Sunny Side Up

unread,
Jul 18, 2016, 11:29:30 PM7/18/16
to silverstripe-dev
On 19 July 2016 at 13:18, Robbie Averill <robbie...@gmail.com> wrote:
Hey Nicolaas,

Decoupling web services means that you manage them separately, i.e. separate code, separate infrastructure, separate databases, etc etc. It's a good concept to adopt early on (in my opinion) because it means you can change A without it breaking B (necessarily).

In your case, if you introduced a shared database or connected to one of the sites databases from the other one you immediately introduce a "coupling". This could be avoided by option #1 in that if you implement a REST API between A and B, you could theoretically introduce C, D, and E in between A and B as long as the input/output from the API is the same... hope that makes sense.

That makes a lot of sense.

For similar reasons I actually liked #2 ... setting up a tiny third server with on it a single PHP script offering a basic Restful API of sorts using its own database. For the following reasons: 

1. if one of the main sites gets very busy, it does not end up sending lots of requests to the other site

2. response times will be faster because the "third" website is just a very thin PHP / MYSQL service which can respond much faster than a silverstripe install






Colin Burns

unread,
Jul 18, 2016, 11:29:39 PM7/18/16
to silverst...@googlegroups.com
Personally I don't think you'll add too much to your overhead by being on on DB and on code base. The site I am running has 800,000 products so I'm guessing you commerce site isn't doing that :)

We don't have scammer with just a product listing site at this time.

In the end writing a dedicated API and interacting with that API from the source site will be just as much overhead as dealing with the multi site feature (which is just a single variable to use).

Cheers,
Colin

Colin Burns
M: +1(250)899-1204 (Canada)
P: +61 7 3102 4334 (Australia)
E: ccb...@gmail.com




Colin Burns

unread,
Jul 18, 2016, 11:30:29 PM7/18/16
to silverst...@googlegroups.com
Scammer should read e-commerce.

Colin Burns
M: +1(250)899-1204 (Canada)
P: +61 7 3102 4334 (Australia)
E: ccb...@gmail.com




Nicolaas Thiemen Francken - Sunny Side Up

unread,
Jul 18, 2016, 11:33:01 PM7/18/16
to silverstripe-dev
On 19 July 2016 at 15:29, Colin Burns <ccb...@gmail.com> wrote:
The site I am running has 800,000 products so I'm guessing you commerce site isn't doing that :)


G
​ood guess ;-) ... great to get your feedback on this.​

Michael van Schaik

unread,
Jul 20, 2016, 3:17:11 AM7/20/16
to silverstripe-d.
Hi Nicolaas,

I have a comparable system to '1.' set up using https://github.com/nyeholt/silverstripe-webservices, with the difference that I'm using a third system/install that the others talk to. I just sync the data on the moment it gets requested, for that I'm using a 'virtual' dataobject of which I've overridden the ::get() and write() function to execute the external API call to the other system. The DO::get() returns a regular list of objects so the data can be worked with as usual in SilverStripe (eg show/edit through gridfield).

https://github.com/colymba/silverstripe-restfulapi also seems a good fit for such a setup.

--
Reply all
Reply to author
Forward
0 new messages