天天看點

[CareerCup] 10.1 Client-facing Service 面向客戶伺服器

10.1 Imagine you are building some sort of service that will be called by up to 1000 client applications to get simple end-of-day stock price information (open, close, high, low). You may assume that you already have the data, and you can store it in any format you wish. How would you design the client-facing service which provides the information to client applications? You are responsible for the development, rollout, and ongoing monitoring and maintenance of the feed. Describe the different methods you considered and why you would recommend your approach. Your service can use any technologies you wish, and can distribute the information to the client applications in any mechanism you choose.

這道題是一道設計題,說是有一些資料資訊要給1000個用戶端應用通路,問我們的用什麼樣的面向客戶伺服器來實作所有的功能。根據樹中描述,我們的伺服器需要易于使用者使用,也要易于自己使用,可以易于未來需要的變更修改,高效和可擴充性好,那麼主要有以下三種實作方法:

1. 使用txt檔案,這是最簡單的方法,使用者在FTP伺服器上下載下傳這個文本檔案,這可能一定程度上友善了維護,因為文本檔案易于浏覽和備份,但是通路解析起來很麻煩,尤其是添加了新資料之後。

2. 使用SQL資料庫,讓客戶直接對資料庫操作。好處是我們可以利用資料庫強大的檢索功能找出我們想要的一些條件搜尋結果,資料庫可以回朔,且備份友善,便于客戶內建現有的應用程式。壞處是可能過載了,我們需要整個SQL資料庫的東西來維護,還需要實作額外層來浏覽和維護資料,盡管資料庫很安全,但是我們不能讓使用者通路一些他們不應接觸的資料。

3. 使用XML,如果我們的資料裡固定的格式和固定的大小,例如company_name, open. high, low, losing price. 那麼XML可以寫出如下這樣: