Advice on App/Service Architecture

I’m starting a project that will have a web front end for the users coupled with a database. There will then be a stand-alone service running that will, on a specified interval, poll an API and update the database with the changes it found.

What I need advice on is how the service should be setup. When a user creates an account on the site, I”ll need to create a “hook” in the service that will then go poll the API for that specific user.

I looked at building the service using NodeJS because I could use the non-blocking structure of it along with callbacks then the API returns data that needs to be reflected in the database. I don’t know how I will be able to create more monitors when a user creates an account since it’s already running. Can NodeJS run in a continuous loop as as service?

I am familiar with .Net and could use a Windows Service, but how would that scale with polling when the user numbers grow?

2

I’m still a fuzzy on exactly what you are asking, but based on your comment, I think I can offer some advice. As I understand it, you’re mainly asking what you can be called by a “hook” and then ran in the background (not in real-time) to perform some sort of db-related update based on calls made to an in-house API. I imagine a simple diagram like the following:

 +----------------+                    +------------------+
 |                |                    |                  |
 |   web app      |    after-signup    |    background    |
 |                |+------------------>|    service       |
 |                |   async-call or    |                  |
 +----------------+      "hook"        +------------------+
                                      +  ^       +
                                      |  |       |
                                      |  |       |
                                      |  |       | update db
                             call API |  |       |
                                      |  |       |
                                      |  |       |
                                      v  +       v
                               +----------+     +------------+
                               |          |     |            |
                               |  API     |     |   Database |
                               +----------+     +------------+

So, in regards to how this “async-call” is made, there are a couple of common options that come to mind.

1. Using a Queue

Perhaps something like Redis or RabbitMQ. In this scenario, after the user has signed up, you’re web-application will push some values into the queue (all the data the background service would need). Your background service would then be a program that simply watches the queue in a continuous loop and processes an item when something is found on the queue.

While this is a very simple approach, it does require that you install some sort of queue server inside your infrastructure. In that case, the diagram would change sightly:

 +----------------+                 +---------+             +------------------+
 |                |                 |         |    pop      |                  |
 |   web server   |    push         |         |<-----------+|    background    |
 |                |+--------------->| queue   |+----------->|    service       |
 |                |   async-call    |         |   process   |                  |
 +----------------+                 |         |             +------------------+
                                    +---------+             + ^       +
                                                            | |       |
                                                            | |       |
                                                            | |       | update db
                                                   call API | |       |
                                                            | |       |
                                                            | |       |
                                                            v +       v
                                                     +---------+     +------------+
                                                     |         |     |            |
                                                     |  API    |     |   Database |
                                                     +---------+     +------------+

Fire and Forget

The other approach is to setup a simple web-server as your processing service. All your web-application will need to do is send a fire and forget HTTP request to your service. By fire and forget I mean that you do not wait for a response when you make the HTTP call. You’ll have to check what libraries you’ll need to use for your language of choice to make this happen.

Then your background service, another web service in this case, will accept the request and start it’s processing. Since the calling service is not waiting for a response, there is no rush here.

Node

In either of these scenarios, you can use NodeJS if you’d like. It will work fine for both approaches. However, Ruby’s EventMachine and Python’s Twisted frameworks will do equally as good if evented IO is your goal, in which case I would have to assume that you are planning on handling a high-volume of requests/queue-items from your we application.

Let me know if this answers your question. Like I had mentioned previously, the question seems kind of broad but I answered what I could.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật